Reputation: 51
I will service my django project with uwsgi on Ubuntu Server, but It doesn't run.
I am using python 3.6 but the uwsgi shows me it's 2.7
I changed default python to python3.6 but uwsgi still doesn't work.
This is my command :
uwsgi --http :8001 --home /home/ubuntu/repository/env --chdir
/home/ubuntu/repository/project -w project.wsgi
This is Error message :
*** Starting uWSGI 2.0.18 (64bit) on [Tue Jun 4 21:03:58 2019] ***
compiled with version: 5.4.0 20160609 on 04 June 2019 11:39:14
os: Linux-4.4.0-1079-aws #89-Ubuntu SMP Tue Mar 26 15:25:52 UTC 2019
nodename: ip-172-31-18-239
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /home/ubuntu/repository/charteredbus
*** running under screen session 1636.sbus ***
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/ubuntu/repository/charteredbus
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 15738
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 http bound on :8001 fd 4
spawned uWSGI http 1 (pid: 8402)
uwsgi socket 0 bound to TCP address 127.0.0.1:39614 (port auto-assigned) fd 3
Python version: 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0 20160609]
Set PythonHome to /home/ubuntu/repository/env
ImportError: No module named site
Upvotes: 1
Views: 823
Reputation: 876
For those who cannot (or failed to) build language-independent uwsgi binary by following the second option as mentioned by @GwynBleidD, you can also build a seperate standalone uwsgi binary tied to different python plugin, by:
preserving the previously-built uwsgi binary
clean up previous build by running make clean
in /PATH/TO/UWSGI_SOURCE_FOLDER
running the command YOUR_PYTHON_VERSION uwsgiconfig.py --build
in /PATH/TO/UWSGI_SOURCE_FOLDER
, for example
python3.9 uwsgiconfig.py --build
python3.6 uwsgiconfig.py --build
python3.4 uwsgiconfig.py --build
Upvotes: 1
Reputation: 20559
Unfortunately, uWSGI has to be compiled with python version matching with your virtualenv. That means: if uWSGI was compiled with python 2.7, you cannot use python 3.6 in your virtualenv (and in your Django app).
Fortunately, there are some methods to fix that:
First one is pretty straightforward. All you need to do is change path to uWSGI binary in your startup script to point to uWSGI installed in your virtualenv. (If you're starting uWSGI using systemd, I recommend systemd user units. Just don't forget to run loginctl enable-linger
)
Second one is not that complicated. First you have to install uWSGI without python plugin, then install separate plugins for all python versions you will need. More on that you can find here. There are probably ready plugins in your system package repository if you're using uWSGI from it.
Upvotes: 2
Reputation: 71
The log tells there is no module named site
ImportError: No module named site
I assume site is an django app. did you register this in your INSTALLED_APPS (settings.py)
Otherwise you may need to register your app. (apps.py in the site app)
Please let me know if I helped you.
Jasper
Upvotes: 0