so I am following this tutorial on digital ocean: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
The only thing I am not doing is using the DB engine and I was just going to stick with the SQLite3
engine as the application is only small. I'm getting to the point where I am trying to run the server wgsi file and it's showing a import filename not supported error. I'm not sure how I can get around this.
I have tried running:
python manage.py run_gunicorn 127.0.0.0:8001
But it's saying Unknown command: 'run_gunicorn' and showing the help it's not showing run_gunicorn
Here's my wgsi file (took the project name out):
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xxxx.settings")
from django.core.wgsi import get_wgsi_application
application = get_wgsi_application()
Heres the traceback:
Traceback (most recent call last):
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
worker.init_process()
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
self.wsgi = self.app.wsgi()
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
__import__(module)
ImportError: Import by filename is not supported.
Traceback (most recent call last):
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
worker.init_process()
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
self.wsgi = self.app.wsgi()
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/sanderson-holdings/local/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
__import__(module)
ImportError: Import by filename is not supported.
I've run into similar issues when migrating from manage.py run_gunicorn to actually using the gunicorn command. I found I had to set DJANGO_SETTINGS_MODULE and also the settings in addition to the actual wsgi file.
My project structure:
I run the following command from the root eestecnet folder:
gunicorn --env DJANGO_SETTINGS_MODULE=eestecnet.settings.deployment --settings eestecnet.settings.deployment eestecnet.wsgi
in my settings I also specify:
WSGI_APPLICATION = 'eestecnet.wsgi.application'
I hope this will help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.