Target WSGI script cannot be loaded as a python module and ImportError: No module named 'django'
Target WSGI script cannot be loaded as a python module and ImportError: No module named 'django'
我正在尝试通过 mod_wsgi WSGIDaemon 方法将虚拟 host 我的 django 项目部署到 apache2 中,我正在使用 ubuntu 16.04 并且出现以下错误.
来自 apache2 错误日志:
[Tue Dec 11 11:55:31.748517 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] mod_wsgi (pid=14231): Target WSGI script '/var/www/html/rasa_django/rasa_django/wsgi.py' cannot be loaded as Python module.
[Tue Dec 11 11:55:31.748570 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] mod_wsgi (pid=14231): Exception occurred processing WSGI script '/var/www/html/rasa_django/rasa_django/wsgi.py'.
[Tue Dec 11 11:55:31.748639 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] Traceback (most recent call last):
[Tue Dec 11 11:55:31.748657 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] File "/var/www/html/rasa_django/rasa_django/wsgi.py", line 12, in
[Tue Dec 11 11:55:31.748662 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] from django.core.wsgi import get_wsgi_application
[Tue Dec 11 11:55:31.748677 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] ImportError: No module named 'django'
[Tue Dec 11 11:55:31.787336 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] mod_wsgi (pid=14231): Target WSGI script '/var/www/html/rasa_django/rasa_django/wsgi.py' cannot be loaded as Python module.
[Tue Dec 11 11:55:31.787379 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] mod_wsgi (pid=14231): Exception occurred processing WSGI script '/var/www/html/rasa_django/rasa_django/wsgi.py'.
[Tue Dec 11 11:55:31.787447 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] Traceback (most recent call last):
[Tue Dec 11 11:55:31.787465 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] File "/var/www/html/rasa_django/rasa_django/wsgi.py", line 12, in
[Tue Dec 11 11:55:31.787470 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] from django.core.wsgi import get_wsgi_application
[Tue Dec 11 11:55:31.787484 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] ImportError: No module named 'django'
在我的host文件000-default.conf:
服务器名称 www.rasa_django.com
文档根 /var/www/html/rasa_django
错误日志 /var/www/logs/error.log
CustomLog /var/www/logs/custom.log 组合
Alias /static /var/www/html/rasa_django/static
<Directory /var/www/html/rasa_django/static>
Require all granted
</Directory>
<Directory /var/www/html/rasa_django/rasa_django>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess rasa_django.com python-path=/var/www/html/rasa_django python-home=/home/aarbor_01/env_site1/lib/python3.6/site-packages
WSGIProcessGroup rasa_django.com
WSGIScriptAlias / /var/www/html/rasa_django/rasa_django/wsgi.py
这是我的 wsgi.py 文件:
进口os
从django.core.wsgi导入get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rasa_django.settings')
申请=get_wsgi_application()
根据 docs,如果您使用的是虚拟环境(我假设 env_site1
是),那么您应该将 python-home
指向该环境的根目录环境。
尝试:
WSGIDaemonProcess rasa_django.com python-path=/var/www/html/rasa_django python-home=/home/aarbor_01/env_site1
我按照 link https://github.com/GrahamDumpleton/mod_wsgi/issues/378
解决了这个问题
我正在尝试通过 mod_wsgi WSGIDaemon 方法将虚拟 host 我的 django 项目部署到 apache2 中,我正在使用 ubuntu 16.04 并且出现以下错误.
来自 apache2 错误日志:
[Tue Dec 11 11:55:31.748517 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] mod_wsgi (pid=14231): Target WSGI script '/var/www/html/rasa_django/rasa_django/wsgi.py' cannot be loaded as Python module. [Tue Dec 11 11:55:31.748570 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] mod_wsgi (pid=14231): Exception occurred processing WSGI script '/var/www/html/rasa_django/rasa_django/wsgi.py'. [Tue Dec 11 11:55:31.748639 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] Traceback (most recent call last): [Tue Dec 11 11:55:31.748657 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] File "/var/www/html/rasa_django/rasa_django/wsgi.py", line 12, in [Tue Dec 11 11:55:31.748662 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] from django.core.wsgi import get_wsgi_application [Tue Dec 11 11:55:31.748677 2018] [wsgi:error] [pid 14231:tid 139821891782400] [remote ::1:44748] ImportError: No module named 'django' [Tue Dec 11 11:55:31.787336 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] mod_wsgi (pid=14231): Target WSGI script '/var/www/html/rasa_django/rasa_django/wsgi.py' cannot be loaded as Python module. [Tue Dec 11 11:55:31.787379 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] mod_wsgi (pid=14231): Exception occurred processing WSGI script '/var/www/html/rasa_django/rasa_django/wsgi.py'. [Tue Dec 11 11:55:31.787447 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] Traceback (most recent call last): [Tue Dec 11 11:55:31.787465 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] File "/var/www/html/rasa_django/rasa_django/wsgi.py", line 12, in [Tue Dec 11 11:55:31.787470 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] from django.core.wsgi import get_wsgi_application [Tue Dec 11 11:55:31.787484 2018] [wsgi:error] [pid 14231:tid 139821849777920] [remote ::1:38604] ImportError: No module named 'django'
在我的host文件000-default.conf:
服务器名称 www.rasa_django.com 文档根 /var/www/html/rasa_django 错误日志 /var/www/logs/error.log CustomLog /var/www/logs/custom.log 组合
Alias /static /var/www/html/rasa_django/static
<Directory /var/www/html/rasa_django/static>
Require all granted
</Directory>
<Directory /var/www/html/rasa_django/rasa_django>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess rasa_django.com python-path=/var/www/html/rasa_django python-home=/home/aarbor_01/env_site1/lib/python3.6/site-packages
WSGIProcessGroup rasa_django.com
WSGIScriptAlias / /var/www/html/rasa_django/rasa_django/wsgi.py
这是我的 wsgi.py 文件:
进口os
从django.core.wsgi导入get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rasa_django.settings')
申请=get_wsgi_application()
根据 docs,如果您使用的是虚拟环境(我假设 env_site1
是),那么您应该将 python-home
指向该环境的根目录环境。
尝试:
WSGIDaemonProcess rasa_django.com python-path=/var/www/html/rasa_django python-home=/home/aarbor_01/env_site1
我按照 link https://github.com/GrahamDumpleton/mod_wsgi/issues/378
解决了这个问题