Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zappa package production fails when using --no_venv #2097

Open
woodrad opened this issue May 9, 2020 · 2 comments · May be fixed by #2119
Open

zappa package production fails when using --no_venv #2097

woodrad opened this issue May 9, 2020 · 2 comments · May be fixed by #2119

Comments

@woodrad
Copy link

woodrad commented May 9, 2020

Context

Running zappa package production --no_venv throws TypeError: expected str, bytes or os.PathLike object, not NoneType. This error happens only when running outside of a virtual environment. zappa package production works as expected.

While I believe running zappa outside of a virtual environment using --no_venv is supported (per #835), I understand why this would be a low-priority issue.

Expected Behavior

zappa builds an application package.

Actual Behavior

zappa throws the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 2778, in handle
    sys.exit(cli.handle())
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 512, in handle
    self.dispatch_command(self.command, stage)
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 551, in dispatch_command
    self.package(self.vargs['output'])
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 642, in package
    self.create_package(output)
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 2257, in create_package
    self.zip_path = self.zappa.create_lambda_zip(
  File "/usr/local/lib/python3.8/site-packages/zappa/core.py", line 533, in create_lambda_zip
    split_venv = splitpath(venv)
  File "/usr/local/lib/python3.8/site-packages/zappa/core.py", line 527, in splitpath
    (path, tail) = os.path.split(path)
  File "/usr/local/lib/python3.8/posixpath.py", line 103, in split
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Possible Fix

If running zappa package outside of a virtual environment is not supported, then the resolution to this issue would be removing support for zappa package --no_venv or reverting #1891.

Another option is adding a conditional check to splitpath() to see whether we are running in a virtual environment before running splitpath(venv).

What appetite do the project maintainers have for supporting zappa use outside of virtual environments?

Your Environment

  • Zappa version used: 0.51.0
  • Operating System and Python version: Python 3.8 on Alpine Linux 3.11 (3.8-alpine3.11 Docker image)
  • The output of pip freeze:
argcomplete==1.11.1
boto3==1.13.6
botocore==1.16.6
certifi==2020.4.5.1
cfn-flip==1.2.3
chardet==3.0.4
click==7.1.2
docutils==0.15.2
durationpy==0.5
future==0.18.2
hjson==3.0.1
idna==2.9
jmespath==0.9.5
kappa==0.6.0
pip-tools==5.1.2
placebo==0.9.0
python-dateutil==2.6.1
python-slugify==4.0.0
PyYAML==5.3.1
requests==2.23.0
s3transfer==0.3.3
six==1.14.0
text-unidecode==1.3
toml==0.10.0
tqdm==4.46.0
troposphere==2.6.1
urllib3==1.25.9
Werkzeug==0.16.1
wsgi-request-logger==0.4.6
zappa==0.51.0
  • Your zappa_settings.json: the error can be reproduced no matter what's in zappa_settings.json
@jneves jneves linked a pull request Jun 14, 2020 that will close this issue
@jneves
Copy link
Collaborator

jneves commented Jun 14, 2020

@woodrad any chance you can try it out with #2119 to check if I haven't missed anything else?

@hbrooks
Copy link

hbrooks commented Jul 18, 2020

I have a similar issue. I'm trying to package my app from inside a Docker container. @jneves I checked out your branch and unfortunately it didn't resolve the issue.

  1. pip install git+https://github.com/Miserlou/Zappa.git@bugfix/gh-2097-fix-deploy-with-no-env
  2. zappa package -s ./zappa_settings.json --no_venv yields:�
Calling package for stage dev..
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/zappa/cli.py", line 2778, in handle
    sys.exit(cli.handle())
  File "/usr/local/lib/python3.6/site-packages/zappa/cli.py", line 512, in handle
    self.dispatch_command(self.command, stage)
  File "/usr/local/lib/python3.6/site-packages/zappa/cli.py", line 551, in dispatch_command
    self.package(self.vargs['output'])
  File "/usr/local/lib/python3.6/site-packages/zappa/cli.py", line 642, in package
    self.create_package(output)
  File "/usr/local/lib/python3.6/site-packages/zappa/cli.py", line 2264, in create_package
    disable_progress=self.disable_progress
  File "/usr/local/lib/python3.6/site-packages/zappa/core.py", line 533, in create_lambda_zip
    split_venv = splitpath(venv)
  File "/usr/local/lib/python3.6/site-packages/zappa/core.py", line 527, in splitpath
    (path, tail) = os.path.split(path)
  File "/usr/local/lib/python3.6/posixpath.py", line 107, in split
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

==============
  1. pip freeze:�
argcomplete==1.11.1
boto3==1.14.7
botocore==1.17.7
certifi==2020.6.20
cffi==1.14.0
cfn-flip==1.2.3
chardet==3.0.4
click==7.1.2
cryptography==2.9.2
docutils==0.15.2
durationpy==0.5
Flask==1.1.1
Flask-Cors==3.0.8
Flask-SQLAlchemy==2.4.0
Flask-SQLAlchemy-Session==1.1
future==0.18.2
hjson==3.0.1
idna==2.9
importlib-metadata==1.6.1
itsdangerous==1.1.0
Jinja2==2.11.2
jmespath==0.10.0
kappa==0.6.0
MarkupSafe==1.1.1
mysqlclient==1.4.6
pip-tools==5.2.1
placebo==0.9.0
pycparser==2.20
PyJWT==1.7.1
PyMySQL==0.9.3
pyOpenSSL==19.1.0
python-dateutil==2.6.1
python-slugify==4.0.0
PyYAML==5.3.1
requests==2.24.0
s3transfer==0.3.3
six==1.15.0
SQLAlchemy==1.3.17
text-unidecode==1.3
toml==0.10.1
tqdm==4.46.1
troposphere==2.6.1
urllib3==1.25.9
Werkzeug==0.16.1
wsgi-request-logger==0.4.6
zappa==0.51.0
zipp==3.1.0
```�

1.  My container is `FROM python:3.6`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants