This ended up being a OSx MySQL Improperly Configured Reason: unsafe use of relative path issue but I have left original problem incase reader has same breadcrumb trail.
So this is an odd problem - I'm trying to deploy Django to Apache, ModWSGI on a Mac running OSx but am running into the following error message:
Target WSGI script '/Library/WebServer/local_biems/biems/wsgi.py' does not contain WSGI application
Now:
- local_biems runs ok with python manage.py runserver with no silenced issues. So I believe my project is error free and ready for deployment.
- a test application local_blog runs ok with runserver AND with my virtual host configuration - so I'm assuming from this that Apache and MODWSGI are playing happily together.
- local_biems and local_blog are alongside each other in the /Library/WebServer/ and have identical permissions.
- If I update the file paths in the virtual host, restart apache and do a hard reload of the site I get the error above.
- WSGI files are identical.
What can I try? I've tried the try/catch statement around get_wsgi_application()
try:
application = get_wsgi_application()
print 'WSGI without exception'
except Exception:
print 'handling WSGI exception'
# Error loading applications
if 'mod_wsgi' in sys.modules:
traceback.print_exc()
os.kill(os.getpid(), signal.SIGINT)
time.sleep(2.5)
but same issue. If I remove this and stick with the standard...
Fri Dec 08 08:23:15.188440 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] Traceback (most recent call last):, referer: http://biems.local/
[Fri Dec 08 08:23:15.188471 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] File "/Library/WebServer/local_biems/biems/wsgi.py", line 16, in <module>, referer: http://biems.local/
[Fri Dec 08 08:23:15.188521 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] application = get_wsgi_application(), referer: http://biems.local/
[Fri Dec 08 08:23:15.188542 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application, referer: http://biems.local/
[Fri Dec 08 08:23:15.188599 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] django.setup(set_prefix=False), referer: http://biems.local/
[Fri Dec 08 08:23:15.188615 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/__init__.py", line 27, in setup, referer: http://biems.local/
[Fri Dec 08 08:23:15.188637 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] apps.populate(settings.INSTALLED_APPS), referer: http://biems.local/
[Fri Dec 08 08:23:15.188650 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate, referer: http://biems.local/
[Fri Dec 08 08:23:15.188682 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] raise RuntimeError("populate() isn't reentrant"), referer: http://biems.local/
[Fri Dec 08 08:23:15.188703 2017] [wsgi:error] [pid 16734] [client 127.0.0.1:55348] RuntimeError: populate() isn't reentrant, referer: http://biems.local/
Although I have just commented out all (but 1) of my apps. Strange thing is that this same site is working on a remove Ubuntu VPS no problem!
Ok, so I just copied the database settings from local_biems to the local_blog and I get MYSQL errors.
daviesc@orion:local_biems [0]$ tail -f /var/log/apache2/local_blog.error.log
[Fri Dec 08 08:42:57.704722 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 115, in load_backend, referer: http://biems.local/polls/
[Fri Dec 08 08:42:57.704740 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] return import_module('%s.base' % backend_name), referer: http://biems.local/polls/
[Fri Dec 08 08:42:57.704750 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module, referer: http://biems.local/polls/
[Fri Dec 08 08:42:57.704766 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] __import__(name), referer: http://biems.local/polls/
[Fri Dec 08 08:42:57.704776 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 30, in <module>, referer: http://biems.local/polls/
[Fri Dec 08 08:42:57.704913 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] 'Did you install mysqlclient or MySQL-python?' % e, referer: http://biems.local/polls/
[Fri Dec 08 08:42:57.704934 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib, referer: http://biems.local/polls/
[Fri Dec 08 08:42:57.704941 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so, referer: http://biems.local/polls/
[Fri Dec 08 08:42:57.704946 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] Reason: unsafe use of relative rpath libmysqlclient.18.dylib in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so with restricted binary., referer: http://biems.local/polls/
[Fri Dec 08 08:42:57.704951 2017] [wsgi:error] [pid 16937] [client 127.0.0.1:55911] Did you install mysqlclient or MySQL-python?, referer: http://biems.local/polls/