Reputation: 337
I am trying to run some Django code using uwsgi. When I am within the right virtualenv, it runs fine. But outside of it, when I run it as follows:
uwsgi /home/axial/axial/config.ini
I get this error:
[uWSGI] getting INI configuration from config.ini
*** Starting uWSGI 2.0.15 (64bit) on [Fri Jul 7 23:34:01 2017] ***
compiled with version: 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564) on 29 June 2017 06:51:11
os: FreeBSD-11.1-RC1 FreeBSD 11.1-RC1 #0 r320486: Fri Jun 30 02:25:16 UTC 2017 [email protected]:/usr/obj/usr/src/sys/GENERIC
nodename: axial
machine: amd64
clock source: unix
detected number of CPU cores: 1
current working directory: /usr/home/axial/axial
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 5734
your memory page size is 4096 bytes
detected max file descriptor number: 28467
lock engine: POSIX semaphores
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 2.7.13 (default, Jun 29 2017, 01:17:13) [GCC 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564)]
Set PythonHome to /home/axial/venv/
ImportError: No module named site
My config.ini is as follows:
[uwsgi]
socket = 127.0.0.1:3031
wsgi-file = /home/axial/axial/axial/wsgi.py
workers = 10
virtualenv = /home/axial/venv/
pythonpath = /home/axial/venv/bin/python3
#home = /home/axial/venv/
#chdir = /home/axial/venv/
When within the virtualenv, there is no problem. But I thought specifying the virtualenv in the config.ini would fix this issue? What is causing this?
This is on FreeBSD.
Side note: /home/axial (user directory), the next 'axial' is the source root directory, the next 'axial' is the app directory which contains the wsgi.py file.
Upvotes: 1
Views: 2410
Reputation: 337
Travis, very similar. The problem was python2 vs python3, but that solution did not seem to work.
Currently uwsgi on FreeBSD defaults to python2. You have to recompile it from the ports. I set the following in /etc/make.conf:
PYTHON_VERSION=python3.6
PYTHON_VERSION_MINIMUM=3.6
DEFAULT_VERSIONS=python=python3.6 python2=2.7 python3=3.6
Then I did
cd /usr/ports/www/uwsgi && make install clean
and it worked!
Upvotes: 0
Reputation: 11
It looks like you are running Python 2.7
Python version: 2.7.13 (default, Jun 29 2017, 01:17:13) [GCC 4.2.1 Compatible
FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564)]
but your telling uwsgi to look for Python 3
pythonpath = /home/axial/venv/bin/python3
I'm not positive this will fix all your problems (as I am also struggling with getting uwsgi to work outside the virtual environment) but it's a place to start
You can also try calling the virtual environment's uwsgi binary
/home/axial/venv/bin/uwsgi --ini /home/axial/axial/config.ini
Upvotes: 1