I have my existing Django application running locally on my MacBook. It's directory structure looks something like this:
myproject/
mySite/
__init__.py
settings.py
urls.py
wsgi.py
myApp1/
__init__.py
models.py
views.py
manage.py
requirements.txt
Up until now, I have been using the Django toy webserver to run my app: ./manage.py runserver 0.0.0.0:8000
. But now I want to use gunicorn instead. So I'm following the instructions here.
I do source myVirtualenv/bin/activate && cd myproject && gunicorn mySite.wsgi
. I get the following error:
File "/usr/local/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "myproject/MyApp2/models.py", line 11, in <module>
from caching.base import CachingManager, CachingMixin
ImportError: No module named caching.base
When I run ./manage.py runserver 0.0.0.0:8000
from the same location it works perfectly fine.
Why? Am I doing something wrong? Does Django-Cache-Machine not work with Gunicorn/WSGI? How to work around this issue?
You seem to have installed gunicorn globally rather than within the virtualenv, so the executable is pointing to the global Python and its site-packages directory rather than the one within the virtualenv. Reinstall gunicorn locally.