ubuntu uwsgi No module named ‘django’

ubuntu uwsgi 服务器启动之后 链接服务器提示500, 查看系统日志发现没有找到django模块。但是通过pip命令可以看到已经成功安装了。

猜测可能是python路径搜索问题导致的,随便搜了一下找到这么一篇文章:https://blog.csdn.net/dqchouyang/article/details/78762432

按照上面的方法,定位django安装路径,然后添加到wsgi文件中即可:

添加以下行:

sys.path.append('/home/ubuntu/.local/lib/python3.6/site-packages')

完整日志:

May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: Traceback (most recent call last):
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]:   File "django_pron_hub/wsgi.py", line 12, in <module>
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]:     from django.core.wsgi import get_wsgi_application
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: ModuleNotFoundError: No module named 'django'
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: unable to load app 0 (mountpoint='') (callable not found or import error)
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: *** no app loaded. going in full dynamic mode ***
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: uWSGI running as root, you can use --uid/--gid/--chroot options
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: *** uWSGI is running in multiple interpreter mode ***
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: spawned uWSGI master process (pid: 15504)
May 12 15:14:44 ip-172-31-11-253 systemd[1]: Started uWSGI Emperor.
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: spawned uWSGI worker 1 (pid: 15507, cores: 2)
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: spawned uWSGI worker 2 (pid: 15508, cores: 2)
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: spawned uWSGI worker 3 (pid: 15509, cores: 2)
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: spawned uWSGI worker 4 (pid: 15510, cores: 2)
May 12 15:14:44 ip-172-31-11-253 uwsgi[15504]: *** Stats server enabled on 127.0.0.1:9191 fd: 16 ***
May 12 15:14:48 ip-172-31-11-253 uwsgi[15504]: --- no python application found, check your startup logs for errors ---
May 12 15:14:48 ip-172-31-11-253 uwsgi[15504]: [pid: 15510|app: -1|req: -1/1] 120.192.147.50 () {46 vars in 1042 bytes} [Tue May 12 15:14:48 2020] GET /admin/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
May 12 15:14:48 ip-172-31-11-253 uwsgi[15504]: --- no python application found, check your startup logs for errors ---
May 12 15:14:48 ip-172-31-11-253 uwsgi[15504]: [pid: 15510|app: -1|req: -1/2] 120.192.147.50 () {46 vars in 886 bytes} [Tue May 12 15:14:48 2020] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 1)
May 12 15:14:49 ip-172-31-11-253 uwsgi[15504]: --- no python application found, check your startup logs for errors ---
May 12 15:14:49 ip-172-31-11-253 uwsgi[15504]: [pid: 15509|app: -1|req: -1/3] 120.192.147.50 () {46 vars in 1042 bytes} [Tue May 12 15:14:49 2020] GET /admin/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
May 12 15:14:49 ip-172-31-11-253 uwsgi[15504]: --- no python application found, check your startup logs for errors ---
May 12 15:14:49 ip-172-31-11-253 uwsgi[15504]: [pid: 15510|app: -1|req: -1/4] 120.192.147.50 () {46 vars in 886 bytes} [Tue May 12 15:14:49 2020] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
 
</module>

原创文章,转载请注明: 转载自 obaby@mars

本文标题: 《ubuntu uwsgi No module named ‘django’》

本文链接地址: https://h4ck.org.cn/2020/05/ubuntu-uwsgi-no-module-named-django/

分享文章:

猜你喜欢:

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注