Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django WSGI APACHE ModuleNotFoundError:没有名为';django';_Python_Django_Apache - Fatal编程技术网

Python Django WSGI APACHE ModuleNotFoundError:没有名为';django';

Python Django WSGI APACHE ModuleNotFoundError:没有名为';django';,python,django,apache,Python,Django,Apache,试图在ubuntu服务器18上使用apache和wsgi部署django是一场噩梦,我创建了一个虚拟环境,安装了依赖项,多次重启apache,但apache wsgi在我的虚拟环境中找不到django。 我可以运行manage.py runserver,这样虚拟环境依赖关系就可以了。 我的venv python版本是3.8 这是apache错误日志: [Sun Dec 08 02:09:53.028651 2019] [wsgi:error] [pid 18902:tid 14023576635

试图在ubuntu服务器18上使用apache和wsgi部署django是一场噩梦,我创建了一个虚拟环境,安装了依赖项,多次重启apache,但apache wsgi在我的虚拟环境中找不到django。 我可以运行manage.py runserver,这样虚拟环境依赖关系就可以了。 我的venv python版本是3.8

这是apache错误日志:

[Sun Dec 08 02:09:53.028651 2019] [wsgi:error] [pid 18902:tid 140235766351616] [remote 186.116.79.225:59496]     from django.core.wsgi import get_wsgi_application
[Sun Dec 08 02:09:53.028666 2019] [wsgi:error] [pid 18902:tid 140235766351616] [remote 186.116.79.225:59496] ModuleNotFoundError: No module named 'django'
[Sun Dec 08 02:09:53.335770 2019] [wsgi:error] [pid 18902:tid 140235648796416] [remote 186.116.79.225:59497] mod_wsgi (pid=18902): Target WSGI script '/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py' cannot be loaded as Python module.
[Sun Dec 08 02:09:53.335820 2019] [wsgi:error] [pid 18902:tid 140235648796416] [remote 186.116.79.225:59497] mod_wsgi (pid=18902): Exception occurred processing WSGI script '/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py'.
[Sun Dec 08 02:09:53.335893 2019] [wsgi:error] [pid 18902:tid 140235648796416] [remote 186.116.79.225:59497] Traceback (most recent call last):
[Sun Dec 08 02:09:53.335915 2019] [wsgi:error] [pid 18902:tid 140235648796416] [remote 186.116.79.225:59497]   File "/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py", line 17, in <module>
[Sun Dec 08 02:09:53.335919 2019] [wsgi:error] [pid 18902:tid 140235648796416] [remote 186.116.79.225:59497]     from django.core.wsgi import get_wsgi_application
[Sun Dec 08 02:09:53.335933 2019] [wsgi:error] [pid 18902:tid 140235648796416] [remote 186.116.79.225:59497] ModuleNotFoundError: No module named 'django'
[Sun Dec 08 02:09:53.665977 2019] [wsgi:error] [pid 18902:tid 140235766351616] [remote 186.116.79.225:59498] mod_wsgi (pid=18902): Target WSGI script '/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py' cannot be loaded as Python module.
[Sun Dec 08 02:09:53.666021 2019] [wsgi:error] [pid 18902:tid 140235766351616] [remote 186.116.79.225:59498] mod_wsgi (pid=18902): Exception occurred processing WSGI script '/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py'.
[Sun Dec 08 02:09:53.666097 2019] [wsgi:error] [pid 18902:tid 140235766351616] [remote 186.116.79.225:59498] Traceback (most recent call last):
[Sun Dec 08 02:09:53.666120 2019] [wsgi:error] [pid 18902:tid 140235766351616] [remote 186.116.79.225:59498]   File "/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py", line 17, in <module>
[Sun Dec 08 02:09:53.666124 2019] [wsgi:error] [pid 18902:tid 140235766351616] [remote 186.116.79.225:59498]     from django.core.wsgi import get_wsgi_application
[Sun Dec 08 02:09:53.666139 2019] [wsgi:error] [pid 18902:tid 140235766351616] [remote 186.116.79.225:59498] ModuleNotFoundError: No module named 'django'
[Sun Dec 08 02:09:53.028651 2019][wsgi:error][pid 18902:tid 140235766351616][remote 186.116.79.225:59496]来自django.core.wsgi导入获取wsgi应用程序
[Sun Dec 08 02:09:53.028666 2019][wsgi:error][pid 18902:tid 140235766351616][remote 186.116.79.225:59496]模块无边界错误:没有名为“django”的模块
[Sun Dec 08 02:09:53.335770 2019][wsgi:error][pid 18902:tid 140235648796416][remote 186.116.79.225:59497]mod_wsgi(pid=18902):目标wsgi脚本'/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py'不能作为Python模块加载。
[Sun Dec 08 02:09:53.335820 2019][wsgi:error][pid 18902:tid 140235648796416][remote 186.116.79.225:59497]mod_wsgi(pid=18902):处理wsgi脚本'/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py'时发生异常。
[Sun Dec 08 02:09:53.335893 2019][wsgi:error][pid 18902:tid 140235648796416][remote 186.116.79.225:59497]回溯(最近一次呼叫最后一次):
[Sun Dec 08 02:09:53.335915 2019][wsgi:error][pid 18902:tid 140235648796416][remote 186.116.79.225:59497]文件“/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py”,第17行,in
[Sun Dec 08 02:09:53.335919 2019][wsgi:error][pid 18902:tid 140235648796416][remote 186.116.79.225:59497]来自django.core.wsgi导入获取wsgi应用程序
[Sun Dec 08 02:09:53.335933 2019][wsgi:error][pid 18902:tid 140235648796416][remote 186.116.79.225:59497]模块未找到错误:没有名为“django”的模块
[Sun Dec 08 02:09:53.665977 2019][wsgi:error][pid 18902:tid 140235766351616][remote 186.116.79.225:59498]mod_wsgi(pid=18902):目标wsgi脚本'/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py'不能作为Python模块加载。
[Sun Dec 08 02:09:53.666021 2019][wsgi:error][pid 18902:tid 140235766351616][remote 186.116.79.225:59498]mod_wsgi(pid=18902):处理wsgi脚本'/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py'时发生异常。
[Sun Dec 08 02:09:53.666097 2019][wsgi:error][pid 18902:tid 140235766351616][remote 186.116.79.225:59498]回溯(最近一次呼叫最后一次):
[Sun Dec 08 02:09:53.666120 2019][wsgi:error][pid 18902:tid 140235766351616][remote 186.116.79.225:59498]文件“/var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py”,第17行,in
[Sun Dec 08 02:09:53.666124 2019][wsgi:error][pid 18902:tid 140235766351616][remote 186.116.79.225:59498]来自django.core.wsgi导入获取wsgi应用程序
[Sun Dec 08 02:09:53.666139 2019][wsgi:error][pid 18902:tid 140235766351616][remote 186.116.79.225:59498]模块无边界错误:没有名为“django”的模块
我不知道该怎么办

这是我的/etc/apache2/sites available/000-default.conf文件:

<VirtualHost *:80>

        Alias /static /var/www/iotconfigserver/IOT_config_rest/static

        <Directory /var/www/iotconfigserver/IOT_config_rest/static>
                Require all granted
        </Directory>

        <Directory /var/www/iotconfigserver/IOT_config_rest/IOT_config_rest >
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIDaemonProcess IOT_config_rest python-home=/var/www/iotconfigserver/venv python-path=/var/www/iotconfigserver/IOT_config_r$        
    WSGIProcessGroup IOT_config_rest
        WSGIScriptAlias / /var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py
</VirtualHost>

别名/static/var/www/iotconfigserver/IOT\u config\u rest/static
要求所有授权
要求所有授权
WSGIDaemonProcess IOT_config_rest python home=/var/www/iotconfigserver/venv python path=/var/www/iotconfigserver/IOT_config_r$
WSGIProcessGroup物联网配置休息
WSGIScriptAlias//var/www/iotconfigserver/IOT_config_rest/IOT_config_rest/wsgi.py

感谢所有试图帮助我的人

我可以通过将python venv降级到3.6来部署,但我仍然不知道为什么

这是因为mod_wsgi模块是用python3.6编译的,因此使用的是python3.6库(其中没有安装django),而不是运行在py3.8上的venv