簡體   English   中英

導入錯誤:沒有用於 wsgi 服務器設置的名為 django.core.wsgi 的模塊

[英]ImportError: No module named django.core.wsgi for wsgi server setting

我正在設置 djano 和 uwsgi

$uwsgi --ini uwsgi.ini

我的 Django 根在這里/var/www/html/myapp/current

它必須是非常簡單的設置,但我還不確定。

我有這兩個文件

/var/www/html/myapp/current/myapp/settings.py /var/www/html/myapp/current/myapp/wsgi.py

[uwsgi]
chdir=/var/www/html/myapp/current #it success
module=myapp.wsgi:application #it success
env DJANGO_SETTINGS_MODULE=myapp.settings # it success
http-socket = 0.0.0.0:8008
processes = 1
threasds = 1
master = 1
max-requests = 100000

錯誤如下,但我無法挖掘詳細的日志。

spawned uWSGI worker 1 (pid: 27353, cores: 1)
--- no python application found, check your startup logs for errors ---
[pid: 27353|app: -1|req: -1/1] 172.17.1.143 () {28 vars in 334 bytes} [Thu Mar 26 17:37:01 2020] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

並且發生此錯誤。

*** Operational MODE: single process ***
Traceback (most recent call last):
  File "./myapp/wsgi.py", line 13, in <module>
    from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1705)
spawned uWSGI worker 1 (pid: 1706, cores: 1)
spawned uWSGI http 1 (pid: 1707)

錯誤發生在這里

from django.core.wsgi import get_wsgi_application

我也在使用anaconda3

$conda activate py37然后

啟動這個命令

$uwsgi --ini uwsgi.ini

我解決了這個問題,問題是 uwsgi 本身。

我的設置文件沒問題。

通過conda安裝conda

conda install -c conda-forge libiconv

conda install -c conda-forge uwsgi

然后啟動uwsgi /home/ubuntu/anaconda3/envs/py37/bin/uwsgi --ini uwsgi.ini

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM