{"errorMessage": "Unable to import module 'app'"}
See original GitHub issueThis error could be related to this issue https://github.com/awslabs/chalice/issues/105
My app.py
is importing a 3rdparty module like
from chalice import Chalice
from empythy import EmpathyMachines;
that I have successfully installed via pip install --upgrade -r requirements.txt
as explained in the related issue, but it seems it has not been deployed correctly by chalice on the lambda machine.
My virtualenv looks like this
(env) admin@macbookproloreto:~/Developmemt/ParisiLabs/ML/tutorials/lambda-sentiment/env$ tree -d -L 4
.
βββ bin
βββ include
βΒ Β βββ python2.7 -> /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
βββ lib
βββ python2.7
βββ config -> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config
βββ distutils
βββ encodings -> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings
βββ lib-dynload -> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
βββ site-packages
βββ empythy
βββ empythy-0.5.6.dist-info
βββ nltk
βββ nltk-3.2.1.dist-info
βββ numpy
βββ numpy-1.11.1.dist-info
βββ pip
βββ pip-8.1.2.dist-info
βββ pkg_resources
βββ scikit_learn-0.17.1.dist-info
βββ scipy
βββ scipy-0.18.0.dist-info
βββ setuptools
βββ setuptools-25.2.0.dist-info
βββ sklearn
βββ wheel
βββ wheel-0.29.0.dist-info
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
python - "errorMessage": "Unable to import module 'app': No ...
Now I'm getting another error saying βunable to import module app: no module named requestsβ My current version of python is 3.10.2 and...
Read more >Resolve "Unable to import module" errors from Python ... - AWS
You typically receive this error when your Lambda environment can't find the specified library in the Python code. This is because LambdaΒ ...
Read more >Unable to import module 'lambda_function' - AWS re:Post
I get the following error when I attempt to test the lambda function. What I am I missing? { "errorMessage": "Unable to import...
Read more >Unable to import module lambda function No ... - Edureka
Hi@akhtar,. This error appears when you haven't named your code file or function correctly. You need to go to Lambda -> Functions ->...
Read more >Prisma cloud[ERROR] Runtime.ImportModuleError: Unable to ...
We are getting the following error in our Lambdas, [ERROR] Runtime.ImportModuleError: Unable to import module 'twistlock': Failed to import - 404799.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As for numpy/binary file support I have a few ideas for how to making working with both C extensions as well as custom binaries easier.
I see two ways to go (maybe itβs worth doing both):
First one: Provide a hook into adding arbitrary data into the deployment zip file we send to lambda. That way as weβre adding files to the zip file we can give you a chance to inject any prebuilt binaries. I think that supporting a βon-buildβ hook would make this possible, something generic like:
chalice deploy
would call thehooks/building-zip
script if it existed.This is probably more useful to address #42.
The second option is to try to leverage the manylinux1 wheels. Iβm not exactly sure how to plumb this in, but many libraries are starting to provide manylinux wheel files (numpy, sklearn)
The latest version of pip letβs you override the platform/arch to use, so the idea would be to ask it to use manlinux wheelsβs when building out the virtualenv to send to lambda. Iβd have to experiment with this approach more to see if I could get it working, but the benefit of this approach would be that it would βjust workβ, you wouldnβt have to do anything (provided your 3rd party librarys have manylinux1 wheels).
Basically the idea to make this work is to compile the required non-python extensions in the same environment as the environment that Lambda runs, which is an Amazon Linux instance, and include them in the zipped package.
I donβt know how this can be integrated into chalice but here are 2 related links: http://stackoverflow.com/questions/34749806/using-moviepy-scipy-and-numpy-in-amazon-lambda http://www.perrygeo.com/running-python-with-compiled-code-on-aws-lambda.html