A
A
AntonIgin2017-09-10 23:40:42
Django
AntonIgin, 2017-09-10 23:40:42

ImportError: No module named site - how to fix this and force the ini file to take python3 instead of python2?

The essence of the problem is described in the title.
If I go into a virtual environment where python 3.5 is enabled and run this:
uwsgi --ini company_uwsgi.ini
Everything works fine, the project is included. But as soon as you exit the environment and type in the same command, an error pops up.
traceback:

[email protected]:~/Django-u/company_base$ uwsgi --ini company_uwsgi.ini
[uWSGI] getting INI configuration from company_uwsgi.ini
*** Starting uWSGI 2.0.15 (64bit) on [Mon Sep 11 03:28:30 2017] ***
compiled with version: 5.4.0 20160609 on 20 July 2017 18:13:34
os: Linux-4.10.0-33-generic #37~16.04.1-Ubuntu SMP Fri Aug 11 14:07:24 UTC 2017
nodename: anton-X451CA
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /home/anton/Django-u/company_base
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/anton/Django-u/company_base/
your processes number limit is 15083
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/anton/Django-u/company_base/company.sock fd 3
Python version: 2.7.12 (default, Nov 19 2016, 06:48:10)  [GCC 5.4.0 20160609]
Set PythonHome to /home/anton/virtenvs/com_env/
ImportError: No module named site
VACUUM: unix socket /home/anton/Django-u/company_base/company.sock removed.

In general, the source of the problem is clear, you need to somehow configure it so that the ini file selects exactly python3. But how?
Here is the current text of company_uwsgi.ini
[uwsgi]

chdir           = /home/anton/Django-u/company_base/
module          = company_base.wsgi
home            = /home/anton/virtenvs/com_env/
master          = true
processes       = 10
socket          = /home/anton/Django-u/company_base/company.sock
chmod-socket    = 666
vacuum          = true

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PrAw, 2017-09-11
@AntonIgin

[uwsgi]
plugins-dir = /usr/lib/uwsgi/plugins
plugin = python3
How to install a plugin for your system - see the documentation :)
How I installed:
apt-get install uwsgi-plugin-python 3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question