WStanley
@WStanley
Back-end Developer

Как исправить ошибку uwsgi ModuleNotFoundError: No module named 'django'?

Настраиваю новый сервак вот конфиги
uwsgi+supervisor+nginx

[uwsgi]
virtualenv = /home/nameuser/srisovki/venv_srisovki
home = /home/nameuser/srisovki/venv_srisovki
chdir = /home/nameuser/srisovki/srisovki
uid = nameuser
gid = nameuser
env = LANG=ru_RU.UTF-8
env = DJANGO_SETTINGS_MODULE=vsesrisovki.settings.prod
module = vsesrisovki.wsgi:application
plugins = python3
master = true
chmod-socket = 666
socket = /home/nameuser/srisovki/configs/srisovki.sock
wsgi-file = /home/nameuser/srisovki/srisovki/vsesrisovki/wsgi.py
processes = 9
threads = 2
enable-threads = true
vacuum = true
touch-reload = /home/nameuser/srisovki/configs/touch

[program:srisovki]
user = nameuser
group = nameuser
directory = /home/nameuser/srisovki/srisovki
command = /usr/local/bin/uwsgi --ini /home/nameuser/srisovki/configs/uwsgi.ini
autostart = true
autorestart = true
stderr_logfile = /var/log/supervisor/srisovki_err.log
stdout_logfile = /var/log/supervisor/srisovki_out.log
stopsignal = QUIT


Ошибка
[uWSGI] getting INI configuration from /home/nameuser/srisovki/configs/uwsgi.ini
*** Starting uWSGI 2.0.18 (64bit) on [Sun Apr  5 15:00:02 2020] ***
compiled with version: 7.5.0 on 05 April 2020 07:35:08
os: Linux-4.15.0-91-generic #92-Ubuntu SMP Fri Feb 28 11:09:48 UTC 2020
nodename: s5
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /home/nameuser/srisovki/srisovki
detected binary path: /usr/local/bin/uwsgi
chdir() to /home/nameuser/srisovki/srisovki
your processes number limit is 30769
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 bound to UNIX address /home/nameuser/srisovki/configs/srisovki.sock fd 3
Python version: 3.6.9 (default, Nov  7 2019, 10:44:02)  [GCC 8.3.0]
PEP 405 virtualenv detected: /home/nameuser/srisovki/venv_srisovki
Set PythonHome to /home/nameuser/srisovki/venv_srisovki
Python main interpreter initialized at 0x56337e9bbfa0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 833760 bytes (814 KB) for 18 cores
*** Operational MODE: preforking+threaded ***
Traceback (most recent call last):
  File "./vsesrisovki/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)
Traceback (most recent call last):
  File "/home/nameuser/srisovki/srisovki/vsesrisovki/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 ***
spawned uWSGI master process (pid: 16440)
spawned uWSGI worker 1 (pid: 16441, cores: 2)
spawned uWSGI worker 2 (pid: 16442, cores: 2)
spawned uWSGI worker 3 (pid: 16443, cores: 2)
spawned uWSGI worker 4 (pid: 16444, cores: 2)
spawned uWSGI worker 5 (pid: 16445, cores: 2)
spawned uWSGI worker 6 (pid: 16446, cores: 2)
spawned uWSGI worker 7 (pid: 16447, cores: 2)
spawned uWSGI worker 8 (pid: 16448, cores: 2)
spawned uWSGI worker 9 (pid: 16449, cores: 2)
unable to stat() /home/nameuser/srisovki/configs/touch, events will be triggered as soon as the file is created
--- no python application found, check your startup logs for errors ---
[pid: 16445|app: -1|req: -1/1] 94.154.82.235 () {42 vars in 752 bytes} [Sun Apr  5 15:00:04 2020] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 16442|app: -1|req: -1/2] 94.154.82.235 () {44 vars in 719 bytes} [Sun Apr  5 15:00:05 2020] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
SIGINT/SIGQUIT received...killing workers...
worker 5 buried after 0 seconds
worker 1 buried after 1 seconds
worker 2 buried after 1 seconds
worker 3 buried after 1 seconds
worker 4 buried after 1 seconds
worker 6 buried after 1 seconds
worker 7 buried after 1 seconds
worker 8 buried after 1 seconds
worker 9 buried after 1 seconds
goodbye to uWSGI.
VACUUM: unix socket /home/nameuser/srisovki/configs/srisovki.sock removed.


В виртуальном окружении у меня python3.8 а тут пишет -> Python version: 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0]
Как заставить uwsgi работать с виртуального окружения?
Или дело в правах? Что посмотреть? куда глянуть? Когда все это кончится?

p.s. django в виртуальном окружении установлен -> ModuleNotFoundError: No module named 'django'
  • Вопрос задан
  • 115 просмотров
Решения вопроса 1
@bacon
Что-то старое у вас, а у меня всё выглядит примерно так:
[uwsgi]
chdir = %d
wsgi-file = %dvsesrisovki/wsgi.py
socket = %dsocket/uwsgi.sock
master = True
processes = 2
vacuum = True
uid = nameuser
gid = nameuser
touch-reload = %drestart_uwsgi
logto = %dlog/uwsgi.log

только я ставлю uwsgi в виртуальное окружение, часть незначимых для вопроса параметров убрал, и тут socket и log в директории проекта, копировал с дев-сервера.
PS и supervisor в топку, есть systemd
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы