Search code examples
pythonherokuflaskvirtualenvpycrypto

Heroku -- ImportError: No module named Crypto


I am trying to deploy a Flask app via Heroku, but the app keeps crashing, and in heroku logs, I get:

2015-01-20T06:26:40.553579+00:00 app[web.1]: from Crypto import Random
2015-01-20T06:26:40.553639+00:00 app[web.1]: ImportError: No module named Crypto
2015-01-20T06:26:40.553531+00:00 app[web.1]: from ZiggeoAuth import ZiggeoAuth
2015-01-20T06:26:41.333576+00:00 heroku[web.1]: Process exited with status 1
2015-01-20T06:26:41.340320+00:00 heroku[web.1]: State changed from starting to crashed.

I've tried using virtualenv and gunicorn and also deploying outside of virtuanlenv, but the import error remains. Running foreman start runs without errors. The requirements.txt generated by pip freeze yields:

Django==1.6.2  
Flask==0.10.1  
Jinja2==2.7.3  
MarkupSafe==0.23  
MySQL-python==1.2.5  
Pillow==2.4.0  
PyRSS2Gen==1.0.0  
South==0.8.4  
Twisted==12.2.0  
Werkzeug==0.9.6  
altgraph==0.10.1  
bdist-mpkg==0.4.4  
beautifulsoup4==4.3.2  
bonjour-py==0.3  
cffi==0.8.6  
cryptography==0.7.2  
django-twitter-bootstrap==3.1.1  
enum34==1.0.4  
itsdangerous==0.24  
macholib==1.5  
matplotlib==1.1.1  
modulegraph==0.10.1  
numpy==1.6.2  
pep8==1.5.7  
py2app==0.7.1  
pyOpenSSL==0.13  
pyasn1==0.1.7  
pycparser==2.10  
**pycrypto==2.6.1**  
pyobjc-core==2.3.2a0  
... (other pyobjc things) ...  
python-dateutil==1.5  
pytz==2012d  
requests==2.4.3  
scipy==0.11.0  
six==1.9.0  
vboxapi==1.0  
virtualenv==1.11.4  
wsgiref==0.1.2  
wxPython==3.0.1.1  
wxPython-common==3.0.1.1  
xattr==0.6.4  
zope.interface==3.8.0

Something that might be important is that I manually installed PyCrypto rather than using Pip, since it didn't work with any package managers. I'm wondering if it's a configuration or pathing issue, but I don't know how to check. heroku config says that the app has no config vars.


Solution

  • Solved: appended the flag --no-site-packages to virtualenv.