WSGI:错误PID 131476:TID 140411361216256远程200.110.48.158:35204 ModulenotFoundError:无模块名称' django.core.core.core.core'

发布于 2025-02-08 13:23:59 字数 4792 浏览 2 评论 0原文

[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>
'''

这些是我正确安装的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()

,适用于Python 3.8 权限

我也给了所有工作文件的权限,但没有任何事情发生

Drwx - x - x-x 9 root 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) ####

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

[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'

These are my all working files

**#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>
'''

i installed mod_wsgi correctly for python 3.8

 **#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()

permissions

also i have given permissions to all the working files but nothing happened

drwx--x--x 9 root root 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) ####

i have tried all the ways but couldn't solve this issue. please try to help me out as much as quickly

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有深☉意 2025-02-15 13:23:59

在您的wsgi.py中尝试尝试导入django首先(导入django),然后在行之后os.environ.setDefault('django_settings_module','server.server.settings' ) add:

django.setup()

查看有关此在这里

另外,您还需要更改导入的顺序,以便导入get_wsgi_application get_wsgi_application < /代码>完成此操作。

In your wsgi.py try importing Django first (import django) and then after the line os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings') add:

django.setup()

Check out the docs regarding this here

Also, you'll need to change the order of imports so that you import get_wsgi_application after you've done this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文