Skip to content

zappa package production fails when using --no_venv #2097

@woodrad

Description

@woodrad

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions