I'm trying to migrate a functional Django application from Webfaction to OpalStack. The app works just fine when I run it using python manage.py runserver
. However, once I try to set up the uWSGI server using the uwsgi.ini
file provided by OpalStack, it simply cannot find my Django settings module! The really, really bizzarre thing is that if I hack the uwsgi.py
file in my Django application, the Django application is properly being added to sys.path
. I have the following in the uwsgi.ini
file (yes, the dailycues/dailycues
is correct based on my project structure):
python-path = /home/bburan/apps/dc_dev/dailycues/dailycues
Then, in the uwsgi.py
file I have added the following:
import sys
print(sys.path)
from dailycues.settings import base
print(base)
In the uWSGI log, I see the following output:
added /home/bburan/apps/dc_dev/dailycues/dailycues/ to pythonpath.
# From print(sys.path)
['/home/bburan/apps/dc_dev/dailycues/dailycues/', '.', '', '/usr/lib64/python36.zip', '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', '/home/bburan/apps/dc_dev/env/lib64/python3.6/site-packages', '/home/bburan/apps/dc_dev/env/lib/python3.6/site-packages']
# from print(development)
<module 'dailycues.settings.base' from '/home/bburan/apps/dc_dev/dailycues/dailycues/dailycues/settings/base.py'>
But then, I get the following error after all of that has successfully executed (i.e., pythonpath is set properly and my settings module is importable) and Django's get_wsgi_application()
is called!
Traceback (most recent call last):
File "/home/bburan/apps/dc_dev/dailycues/dailycues/main/wsgi.py", line 36, in <module>
application = get_wsgi_application()
File "/home/bburan/apps/dc_dev/env/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/home/bburan/apps/dc_dev/env/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/bburan/apps/dc_dev/env/lib/python3.6/site-packages/django/conf/__init__.py", line 83, in __getattr__
self._setup(name)
File "/home/bburan/apps/dc_dev/env/lib/python3.6/site-packages/django/conf/__init__.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "/home/bburan/apps/dc_dev/env/lib/python3.6/site-packages/django/conf/__init__.py", line 177, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named '"dailycues'
This is pretty perplexing to me. It seems that somehow the python path is getting messed up. Any pointers?