django,pyenv,uwsgi - ModuleNotFoundError:没有名为'django'的模块

tgy*_*tgy 3 python django uwsgi pyenv

我有以下附庸配置/etc/uwsgi/vassals/gsd.ini:

[uwsgi]
plugins = python
env = DJANGO_SETTINGS_MODULE=%n.settings
virtualenv = /home/toogy/.pyenv/versions/%n
chdir = /home/webapps/%n
module = %n.wsgi:application
master = true
vacuum = true
pidfile = /tmp/uwsgi-%n.pid
socket = /tmp/uwsgi-%n.sock
daemonize = /var/log/uwsgi/%n.log
chmod-socket = 666
uid = toogy
gid = toogy
Run Code Online (Sandbox Code Playgroud)

这是我得到的uwsgi日志

Tue Feb  7 10:49:12 2017 - received message 1 from emperor
...gracefully killing workers...
Gracefully killing worker 1 (pid: 31406)...
worker 1 buried after 1 seconds
binary reloading uWSGI...
chdir() to /etc/uwsgi/vassals
closing all non-uwsgi socket fds > 2 (max_fd = 1024)...
found fd 3 mapped to socket 0 (/tmp/uwsgi-gsd.sock)
running /usr/bin/uwsgi
*** has_emperor mode detected (fd: 7) ***
[uWSGI] getting INI configuration from gsd.ini
*** Starting uWSGI 2.0.14 (64bit) on [Tue Feb  7 10:49:13 2017] ***
compiled with version: 6.3.1 20170109 on 18 January 2017 00:35:47
os: Linux-3.14.32-xxxx-grs-ipv6-64 #7 SMP Wed Jan 27 18:05:09 CET 2016
nodename: renard
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/bin/uwsgi
chdir() to /home/webapps/gsd
your processes number limit is 15700
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 inherited UNIX address /tmp/uwsgi-gsd.sock fd 3
Python version: 3.6.0 (default, Jan 16 2017, 12:12:55)  [GCC 6.3.1 20170109]
PEP 405 virtualenv detected: /home/toogy/.pyenv/versions/gsd
Set PythonHome to /home/toogy/.pyenv/versions/gsd
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x39d21f0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
added /home/webapps/gsd/ to pythonpath.
Traceback (most recent call last):
  File "/home/webapps/gsd/gsd/wsgi.py", line 12, in <module>
    from django.core.wsgi import get_wsgi_application
ModuleNotFoundError: No module named 'django'
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 ***
gracefully (RE)spawned uWSGI master process (pid: 27844)
spawned uWSGI worker 1 (pid: 32312, cores: 1)
Run Code Online (Sandbox Code Playgroud)

实在找不到django,我也不知道为什么,因为uwsgi似乎发现Python环境中(其中django 安装).

此外,它说Python version: 3.6.0我的virtualenv Python版本是3.5.2.我不知道这是否应该发生.系统Python版本是3.6.0.

我使用的最后一个版本uwsgiuwsgi-plugins-pythonArch Linux的官方软件包.

tgy*_*tgy 7

问题是链接到uwsgi的系统级python版本需要与virtualenv相同,我认为这是一个非常愚蠢的事情.

  • 你救了我的一天!这确实是一个愚蠢的要求。 (2认同)
  • @valentin 如何验证两者是否相同?如果没有,我该如何修复它们? (2认同)
  • @SaitejaParsi 要了解您的 Python 系统版本:从任何终端输入 `python --version`,并了解 UWSGI Python 版本,只需运行 uwsgi 并阅读日志即可了解正在使用的 UWSGI Python 版本。我当时修复它的方法是使用 UWSGI 使用的 Python 版本创建一个新的 env。 (2认同)
  • 我很恼火地宣布,情况仍然如此。这篇文章需要更多的点赞。 (2认同)