Open johey opened 7 years ago
Hi!
Just tested this here and it worked fine for me, using the same Python version and requirements file., although I'm using OSX.
Did you put the same bucket named used in zappa_settings.json
in the BUCKET_NAME
variable inside my_app.py
?
Ok, thanks for testing it out! That is strange indeed. Yes, I am consistent regarding bucket name. Will spend some more time trying to understand what is causing the problem.
I'll try to get a Windows machine to test it out too. If you have any updates, please let us know!
Just tried on a GNU/Linux machine. Works perfectly! Now I'm happy. Who needs Windows anyway. :) Yet, I'll leave the issue open, as there actually seems to be a problem.
Thats awesome @johey! Let's wais if any contributor with a Windows machine could test it out!
I think I've got a work-around for Windows (using Python 2.7):
The fix is to try really hard to make sure that you upload the precompiled lambda package version of Pillow instead of your local Windows-friendly version of Pillow:
./{venv-name}/Lib/site-packages/pillow
so that zappa.core.Zappa.get_installed_packages
knows that you are using pillowzappa update
and you should see pillow==3.4.2: Using precompiled lambda package
(which implies success)You can get a feel for what's going on by reading zappa.core.Zappa.get_installed_packages
and zappa.core.Zappa.create_lambda_zip
and then playing with the following code:
import os
import pip
import subprocess
from pprint import pprint as p
from lambda_packages import lambda_packages as lambda_packages_orig
from zappa.core import Zappa
lambda_packages = {package_name.lower(): val for package_name, val in lambda_packages_orig.items()}
p(lambda_packages['pillow'])
z = Zappa()
venv = z.get_current_venv()
site_packages = os.path.join(venv, 'Lib', 'site-packages')
print "\nPACKAGES IN SITE PACKAGES\n"
p(os.listdir(site_packages))
print "\nPIP INSTALLED PACKAGES\n"
p({
package.project_name.lower(): package.version
for package in pip.get_installed_distributions()
})
print "\nFINAL INSTALLED PACKAGES\n"
installed_packages = z.get_installed_packages(site_packages, '')
p(installed_packages)
just leaving the note I was getting similar error but with flask:
[1554818782296] cannot import name 'Flask': ImportError
zappa initial touch after deploy also failed with http 502 due to this
as this thread suggested, I was using Windows and slim option, tried running same code on docker python image (ubuntu), problem solved! thanks! :)
Trying to follow Rich Jones - "Building Serverless Microservices with Zappa and Flask" tutorial. It works perfectly fine until I add dependency towards Pillow. Locally it continues working fine, using Flask webserver, but deployed on AWS using Zappa, it failes on
ImportError: cannot import name _imaging
.Expected Behavior
Function should work, presenting me with a web page.
Actual Behavior
I get a json error in the web browser:
"{u'message': u'An uncaught exception happened while servicing this request. You can investigate this with the
zappa tailcommand.', u'traceback': ['Traceback (most recent call last):\\n', ' File \"/var/task/handler.py\", line 427, in handler\\n response = Response.from_app(self.wsgi_app, environ)\\n', ' File \"c:\\\\users\\\\johan\\\\appdata\\\\local\\\\temp\\\\pip-build-s_0wot\\\\Werkzeug\\\\werkzeug\\\\wrappers.py\", line 903, in from_app\\n', ' File \"c:\\\\users\\\\johan\\\\appdata\\\\local\\\\temp\\\\pip-build-s_0wot\\\\Werkzeug\\\\werkzeug\\\\test.py\", line 884, in run_wsgi_app\\n', \"TypeError: 'NoneType' object is not callable\\n\"]}"
Output from zappa tail:
Steps to Reproduce
Your Environment
pip freeze
:zappa_settings.py
: