My Django project has this directory structure:
.
├── gnjp
│ ├── gnjp
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── app1
│ ├── app2
│ ├── manage.py
│ └── templates
├── bin
├── include
├── lib
using a virtual environment and works fine with python manage.py runserver
using some pip-installed modules like django-bootstrap4, django-bootstrap-datepicker-plus.
From the higher-level gnjp-directory I do gunicorn gnjp.wsgi
and get this error:
[2019-09-07 14:20:28 +0200] [72408] [INFO] Starting gunicorn 19.9.0
[2019-09-07 14:20:28 +0200] [72408] [INFO] Listening at: http://127.0.0.1:8000 (72408)
[2019-09-07 14:20:28 +0200] [72408] [INFO] Using worker: sync
[2019-09-07 14:20:28 +0200] [72411] [INFO] Booting worker with pid: 72411
[2019-09-07 14:20:28 +0200] [72411] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
File "/..../gnjp/gnjp/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'bootstrap_datepicker_plus'
[2019-09-07 14:20:28 +0200] [72411] [INFO] Worker exiting (pid: 72411)
[2019-09-07 14:20:28 +0200] [72408] [INFO] Shutting down: Master
[2019-09-07 14:20:28 +0200] [72408] [INFO] Reason: Worker failed to boot.
I can see the bootstrap-datepicker-plus in site-packages in the virtual environment.
Some parts of my settings.py that might be relevant:
INSTALLED_APPS = [
'app1',
'app2'
'bootstrap4',
'bootstrap_datepicker_plus'
]
WSGI_APPLICATION = 'gnjp.wsgi.application'
My gnjp/wsgi.py
has this content:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'gnjp.settings')
application = get_wsgi_application()
Try adding this at the start of your wsgi
file:
python_home='/path/to/your/venv'
activate_this=python_home+'/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
assuming that you created your virtual environment using virtualenv
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.