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

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

安装 uwsgi

conda install -c conda-forge libiconv

conda install -c conda-forge uwsgi

然后启动uwsgi /home/ubuntu/anaconda3/envs/py37/bin/uwsgi --ini uwsgi.ini