繁体   English   中英

wsgi:error pid 131476:tid 140411361216256 remote 200.110.48.158:35204 ModuleNotFoundError: No module named 'django.core'

[英]wsgi:error pid 131476:tid 140411361216256 remote 200.110.48.158:35204 ModuleNotFoundError: No module named 'django.core'

[Thu Jun 16 20:32:08.505090 2022] [wsgi:error] [pid 131476:tid 140411386394368] [remote 193.32.127.157:53433] Traceback (most recent call last):
[Thu Jun 16 20:32:08.505133 2022] [wsgi:error] [pid 131476:tid 140411386394368] [remote 193.32.127.157:53433]   File "/root/novo-ai-api-main/backend/server/server/wsgi.py", line 18, in <module>
[Thu Jun 16 20:32:08.505139 2022] [wsgi:error] [pid 131476:tid 140411386394368] [remote 193.32.127.157:53433]     from django.core.wsgi import get_wsgi_application
[Thu Jun 16 20:32:08.505159 2022] [wsgi:error] [pid 131476:tid 140411386394368] [remote 193.32.127.157:53433] ModuleNotFoundError: No module named 'django.core'
[Thu Jun 16 20:48:58.603180 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] mod_wsgi (pid=131476): Failed to exec Python script file '/root/novo-ai-api-main/backend/server/server/wsgi.py'.
[Thu Jun 16 20:48:58.603316 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] mod_wsgi (pid=131476): Exception occurred processing WSGI script '/root/novo-ai-api-main/backend/server/server/wsgi.py'.
[Thu Jun 16 20:48:58.603447 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] Traceback (most recent call last):
[Thu Jun 16 20:48:58.603477 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204]   File "/root/novo-ai-api-main/backend/server/server/wsgi.py", line 18, in <module>
[Thu Jun 16 20:48:58.603483 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204]     from django.core.wsgi import get_wsgi_application
[Thu Jun 16 20:48:58.603506 2022] [wsgi:error] [pid 131476:tid 140411361216256] [remote 200.110.48.158:35204] ModuleNotFoundError: No module named 'django.core'

这些是我所有的工作文件

**#000-default.conf**

<VirtualHost *:80>

        #ServerAdmin webmaster@localhost
        DocumentRoot /root/novo-ai-api-main


        ErrorLog /root/novo-ai-api-main/error.log
        CustomLog /root/novo-ai-api-main/access.log combine


        <Directory /root/novo-ai-api-main/backend/server/server>
                <Files wsgi.py>
                         Require all granted
                </Files>
        </Directory>
        Alias /static /root/novo-ai-api-main/static
        <Directory /root/novo-ai-api-main/static>
                Require all granted
        </Directory>


        WSGIScriptAlias / /root/novo-ai-api-main/backend/server/server/wsgi.py
        WSGIDaemonProcess django_app python-path=/root/novo-ai-api-main/backend/server  python-home=/root/novo-ai-api-main/backend/django/
        WSGIProcessGroup django_app

</VirtualHost>
#apache2.conf
**apache2.conf**
'''
<pre>
ServerRoot "/etc/apache2"
Timeout 300
MaxKeepAliveRequests 100

#KeepAliveTimeout: Number of seconds to wait for the next request from the
#same client on the same connection.
#
KeepAliveTimeout 5

#These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

LogLevel warn

#Sets the default security model of the Apache2 HTTPD server. It does

<Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

<Directory /var/www/>
        AllowOverride All
        Require all granted
</Directory>

<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>


#AccessFileName .htaccess

#<FilesMatch "^\.ht">
#Require all denied
#</FilesMatch>


IncludeOptional conf-enabled/*.conf


IncludeOptional sites-enabled/*.conf

#vim: syntax=apache ts=4 sw=4 sts=4 sr noet



</pre>
'''

我为 python 3.8 正确安装了 mod_wsgi

 **#wsgi.py**

 import os, sys
 import site
 site.addsitedir('/root/novo-ai-api-main/django/lib/python3.8/site-packages')
 from django.core.wsgi import get_wsgi_application
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
 application = get_wsgi_application()

权限

我也授予了所有工作文件的权限,但什么也没发生

drwx--x--x 9 根根 4096 Jun 16 22:05。

drwxr-xr-x 19 root     root       4096 Jun 14 14:05 ..
drwxr-xr-x  3 root     root       4096 Jun 13 23:38 .local
drwxrwxr-x  8 root     root       4096 Jun 16 01:24 mod_wsgi-4.9.2
drwxr-xr-x  5 www-data www-data   4096 Jun 14 23:53 novo-ai-api-main <-(project)
drwxr-xr-x 5 www-data www-data     4096 Jun 14 23:14 backend
drw-r--r-- 8 www-data www-data     4096 Jun 14 00:33 static
drwxr-xr-x 6 www-data www-data 4096 Jun 14 00:16 django <- (venv) ####

我已经尝试了所有方法,但无法解决这个问题。 请尽快帮助我

在您的wsgi.py尝试首先导入 Django( import django ),然后在os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')行之后添加:

django.setup()

在此处查看有关此的文档

此外,您需要更改导入顺序,以便在完成此操作后导入get_wsgi_application

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM