SolvedZappa Error loading psycopg2 module on Python 3.6 (when on Lambda)
✔️Accepted Answer
I solved the issue by installing psycopg2-binary
Other Answers:
psycopg2-binary
worked for me.
i was having this issue:
RuntimeError: populate() isn't reentrant
thank you!
pipenv install psycopg2-binary
also solved the issue for me, but I have 2 questions.
-
Is using
psycopg2-binary
suitable for a production environment? Seems like compiled code would be a good thing, but the docs at https://pypi.org/project/psycopg2-binary/ currently read "The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources." -
If it is necessary for Django to work in a lambda using Zappa, should
psycopg2-binary
be added (or verified) as a dependency in thezappa init
command. That would've saved me time tracking this down.
I'm still getting No module named 'psycopg2._psycopg'
with zappa==0.41.2 and psycopg2==2.7.1
Context
Shiny new Zappa 0.41 and Python 3.6
Django==1.11
djangorestframework==3.6.2
psycopg2==2.6.1
zappa==0.41.0
...
Expected Behavior
It works fine locally, but on Lambda the following happens:
Possible Fix
No idea yet, but before I dig further, I was wondering if someone had any pointers. I assume its something to do with pre-compiled C-extension packages not working on Python 3.6 yet.