Reputation: 4135
As the title says, I can run this simple python/flask app via the terminal just fine:
$ python /srv/www/cc/hello.py
* Running on http://0.0.0.0:8080/
But when I use uwsgi I get the below in my log file:
Traceback (most recent call last):
File "/srv/www/cc/hello.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
Other threads on here point to a potential version difference with python being the culprit, but I have verified that everything is using the same version via the below:
$ python -c 'import sys; print sys.version'
2.7.6
And in my emperor.log and cc_uwsgi.log files see Python version: 2.7.6
Anyone have any other ideas?
Edit: I can even see the right path to flask in my python path... as well as import it just fine.
$ python -c 'import sys; print sys.path'
[..., '/home/ccadmin/.local/lib/python2.7/site-packages', ...]
$ python -d 'from flask import Flask'
$
Upvotes: 1
Views: 3700
Reputation: 4135
Turns out it was as simple as declaring the path to the site-packages in my uwsgi.ini config, even though it was already showing in my path. Not sure why it was needed again, but it was:
[uwsgi]
pythonpath = /home/ccadmin/.local/lib/python2.7/site-packages/
Upvotes: 3
Reputation: 415
Usually and import error like this is attributed to the PYTHONPATH not being set correctly. Can you set your PYTHONPATH env variable to point to the correct location and try.
Upvotes: 1