serverless-python-requirements
serverless-python-requirements copied to clipboard
Lambda load error: importlib_metadata.PackageNotFoundError: importlib_metadata
Unable to get Lambda loading with the configuration below:
versions
Framework Core: 1.59.3
Plugin: 3.2.5
SDK: 2.2.1
Components Core: 1.1.2
Components CLI: 1.4.0
requirements.txt
boto3==1.9.42
Flask==1.1.1
flask-cors==3.0.8
flask-marshmallow==0.10.1
flask-restplus==0.13.0
marshmallow==3.2.1
python-json-logger==0.1.11
requests==2.22.0
webargs==5.5.1
# bert and TF
tensorflow==1.13.1
bert-tensorflow==1.0.1
beautifulsoup4==4.8.1
serverless.yml snippet
plugins:
- serverless-python-requirements
- serverless-wsgi
custom:
wsgi:
app: app.app
packRequirements: false
pythonRequirements:
dockerImage: lambci/lambda:build-python3.6
# dockerizePip: true
zip: true
slim: false
noDeploy:
- boto3
- botocore
- docutils
- jmespath
- pip
- python-dateutil
- s3transfer
- setuptools
- six
- tensorboard
ERROR on Lambda Load
from .model import Model
File "/tmp/sls-py-req/flask_restplus/model.py", line 15, in <module>
from jsonschema import Draft4Validator
File "/tmp/sls-py-req/jsonschema/__init__.py", line 33, in <module>
import importlib_metadata as metadata
File "/tmp/sls-py-req/importlib_metadata/__init__.py", line 554, in <module>
__version__ = version(__name__)
File "/tmp/sls-py-req/importlib_metadata/__init__.py", line 516, in version
return distribution(distribution_name).version
File "/tmp/sls-py-req/importlib_metadata/__init__.py", line 489, in distribution
return Distribution.from_name(distribution_name)
File "/tmp/sls-py-req/importlib_metadata/__init__.py", line 194, in from_name
raise PackageNotFoundError(name)
importlib_metadata.PackageNotFoundError: importlib_metadata
START RequestId: 263c5ed9-a9ac-4d2a-a61d-84a52a023d75 Version: $LATEST
module initialization error: Unable to import app.app
END RequestId: 263c5ed9-a9ac-4d2a-a61d-84a52a023d75
REPORT RequestId: 263c5ed9-a9ac-4d2a-a61d-84a52a023d75 Duration: 108.10 ms Billed Duration: 200 ms Memory Size: 1024 MB Max Memory Used: 483 MB Init Duration: 4198.33 ms
module initialization error
Unable to import app.app
Traceback (most recent call last):
File "/tmp/sls-py-req/jsonschema/__init__.py", line 31, in <module>
from importlib import metadata
ImportError: cannot import name 'metadata'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/task/wsgi_handler.py", line 44, in import_app
wsgi_module = importlib.import_module(wsgi_fqn_parts[-1])
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 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/var/task/app.py", line 6, in <module>
from industry_classifier.app import create_app
File "/var/task/industry_classifier/app.py", line 6, in <module>
from industry_classifier import api
File "/var/task/industry_classifier/api/__init__.py", line 1, in <module>
from . import views
File "/var/task/industry_classifier/api/views.py", line 2, in <module>
from flask_restplus import Api
File "/tmp/sls-py-req/flask_restplus/__init__.py", line 4, in <module>
from . import fields, reqparse, apidoc, inputs, cors
File "/tmp/sls-py-req/flask_restplus/reqparse.py", line 19, in <module>
from .model import Model
File "/tmp/sls-py-req/flask_restplus/model.py", line 15, in <module>
from jsonschema import Draft4Validator
File "/tmp/sls-py-req/jsonschema/__init__.py", line 33, in <module>
import importlib_metadata as metadata
File "/tmp/sls-py-req/importlib_metadata/__init__.py", line 554, in <module>
__version__ = version(__name__)
File "/tmp/sls-py-req/importlib_metadata/__init__.py", line 516, in version
return distribution(distribution_name).version
File "/tmp/sls-py-req/importlib_metadata/__init__.py", line 489, in distribution
return Distribution.from_name(distribution_name)
File "/tmp/sls-py-req/importlib_metadata/__init__.py", line 194, in from_name
raise PackageNotFoundError(name)
importlib_metadata.PackageNotFoundError: importlib_metadata