【问题标题】:WSGI ERROR :Target WSGI script cannot be loaded as Python moduleWSGI 错误:目标 WSGI 脚本无法作为 Python 模块加载
【发布时间】:2021-11-28 05:24:36
【问题描述】:

我正在尝试使用 apache 部署 Django 应用程序,但出现以下错误

[Fri Oct 08 07:55:44.393237 2021] [wsgi:error] [pid 12424:tid 140450959271680]  mod_wsgi (pid=12424): Target WSGI script '/home/preinstall/hx_preinstaller/hx_preinstaller/wsgi.py' cannot be loaded as Python module.
[Fri Oct 08 07:55:44.393281 2021] [wsgi:error] [pid 12424:tid 140450959271680]  mod_wsgi (pid=12424): Exception occurred processing WSGI script '/home/preinstall/hx_preinstaller/hx_preinstaller/wsgi.py'.
[Fri Oct 08 07:55:44.393408 2021] [wsgi:error] [pid 12424:tid 140450959271680]  Traceback (most recent call last):
[Fri Oct 08 07:55:44.393430 2021] [wsgi:error] [pid 12424:tid 140450959271680]  File "/home/preinstall/hx_preinstaller/hx_preinstaller/wsgi.py", line 12, in <module>
[Fri Oct 08 07:55:44.393435 2021] [wsgi:error] [pid 12424:tid 140450959271680]  from django.core.wsgi import get_wsgi_application
[Fri Oct 08 07:55:44.393446 2021] [wsgi:error] [pid 12424:tid 140450959271680]  ModuleNotFoundError: No module named 'django'

我的 apache 虚拟主机

 <VirtualHost *:80>
   DocumentRoot /home/preinstall/hx_preinstaller
    ErrorLog ${APACHE_LOG_DIR}/preinstall_error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /home/preinstall/hx_preinstaller/hx_preinstaller>
        <Files wsgi.py>
            Require all granted
        </Files>
         </Directory>
                 <Directory /home/preinstall/hx_preinstaller>
                 Require all granted
                 </Directory>
                 WSGIDaemonProcess preinstall python-path=/home/preinstall/hx_preinstaller:/home/preinstall/.local/lib/python3.6/site-packages
                WSGIProcessGroup preinstall
                WSGIPassAuthorization On
                WSGIScriptAlias / /home/preinstall/hx_preinstaller/hx_preinstaller/wsgi.py
</VirtualHost>

我该怎么办?..

【问题讨论】:

    标签: django apache mod-wsgi wsgi wsgiserver


    【解决方案1】:

    也许它是 python 版本不匹配,或者你没有正确地将 python 路径添加到 appache.conf 。 去查看这篇文章以了解有关此错误的更多信息->>> link

    【讨论】:

    • python 版本是一样的顺便说一句。mod_wsgi 的 Python 版本与我安装的类似
    猜你喜欢
    • 2011-09-21
    • 1970-01-01
    • 1970-01-01
    • 2018-01-18
    • 2013-08-27
    • 2018-06-23
    • 2020-05-17
    相关资源
    最近更新 更多