You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Excluding *.egg-info from the package deployed to lambda, when slim_handler: true causes random "DistributionNotFound" errors for packages that do not have dist-info but have egg-info.
I had exactly the problem described in #1555 and after investigation it turned out that pkg_resources ignores packages that do not have dist-info or egg-info directories. After removing the *.egg-info' from ZIP_EXCLUDES in Zappa core.py the code executes without issues!
Expected Behavior
All required files from venv should be included in the lambda package
Actual Behavior
.egg-info directories are missing which is causing DistributionNotFound errors.
The 'sagemaker' distribution was not found and is required by the application: DistributionNotFound
Traceback (most recent call last):
File "/var/task/handler.py", line 567, in lambda_handler
return LambdaHandler.lambda_handler(event, context)
File "/var/task/handler.py", line 237, in lambda_handler
handler = cls()
File "/var/task/handler.py", line 129, in __init__
self.app_module = importlib.import_module(self.settings.APP_MODULE)
File "/var/lang/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/tmp/test-zappa-egginfo/lambda_function.py", line 1, in <module>
import sagemaker
File "/tmp/test-zappa-egginfo/sagemaker/__init__.py", line 15, in <module>
from sagemaker import estimator # noqa: F401
File "/tmp/test-zappa-egginfo/sagemaker/estimator.py", line 23, in <module>
from sagemaker.analytics import TrainingJobAnalytics
File "/tmp/test-zappa-egginfo/sagemaker/analytics.py", line 22, in <module>
from sagemaker.session import Session
File "/tmp/test-zappa-egginfo/sagemaker/session.py", line 28, in <module>
from sagemaker.user_agent import prepend_user_agent
File "/tmp/test-zappa-egginfo/sagemaker/user_agent.py", line 22, in <module>
SDK_VERSION = pkg_resources.require('sagemaker')[0].version
File "/tmp/test-zappa-egginfo/pkg_resources/__init__.py", line 892, in require
needed = self.resolve(parse_requirements(requirements))
File "/tmp/test-zappa-egginfo/pkg_resources/__init__.py", line 778, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'sagemaker' distribution was not found and is required by the application
Modify /usr/local/lib/python3.6/site-packages/zappa/core.py: remove '*.egg-info' from ZIP_EXCLUDES in line 201
zappa update dev
Execute Lambda again, get successful execution.
Your Environment
Zappa version used: 0.46.2
Operating System and Python version: Amazon Linux, Python 3.6.5.
Similar issue happens on MacOS 10.12.6 with Python 3.6.5 for other packages.
Context
Excluding
*.egg-info
from the package deployed to lambda, whenslim_handler: true
causes random "DistributionNotFound" errors for packages that do not havedist-info
but haveegg-info
.Related issues:
I had exactly the problem described in #1555 and after investigation it turned out that
pkg_resources
ignores packages that do not havedist-info
oregg-info
directories. After removing the*.egg-info'
fromZIP_EXCLUDES
in Zappacore.py
the code executes without issues!Expected Behavior
All required files from venv should be included in the lambda package
Actual Behavior
.egg-info
directories are missing which is causingDistributionNotFound
errors.Possible Fix
Remove '*.egg-info' from ZIP_EXCLUDES.
Steps to Reproduce
docker run -it amazonlinux:1 bash
export LANG=en_US.utf8
yum install -y python36-pip python36-devel vim
pip-3.6 install zappa awscli
mkdir /tmp/myproject && cd /tmp/myproject
python -m venv .env
. .env/bin/activate
pip install sagemaker
lambda_function.py
with:zappa_settings.json
(see below)zappa deploy dev
/usr/local/lib/python3.6/site-packages/zappa/core.py
: remove'*.egg-info'
fromZIP_EXCLUDES
in line 201zappa update dev
Your Environment
Similar issue happens on MacOS 10.12.6 with Python 3.6.5 for other packages.
pip freeze
:zappa_settings.py
:The text was updated successfully, but these errors were encountered: