gpt4 book ai didi

django - 目标 WSGI 脚本无法作为 python 模块加载和 ImportError : No module named 'django'

转载 作者:行者123 更新时间:2023-12-04 18:50:40 24 4
gpt4 key购买 nike

我正在尝试通过 mod_wsgi WSGIDaemon 方法将我的 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'



在我的主机文件 000-default.conf 中:

服务器名称 www.rasa_django.com
DocumentRoot/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 文件:

导入操作系统

从 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

关于django - 目标 WSGI 脚本无法作为 python 模块加载和 ImportError : No module named 'django' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53718793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com