I’m trying to deploy a django project with the hoster uberspace. They provide you with access to a linux server where you are one of many users. I was able to succesfully get django running without a virtual environment. Now I’m trying with a virtual environment, but I didn’t have succes as of yet. Here is my uwsgi configuration.
[uwsgi]
project = test_project
uid = devspiff
gid = devspiff
base = /home/devspiff
chdir = %(base)/dj_prj/test_project_venv/test_project/test_project
home = %(base)/dj_prj/test_project_venv/
module = test_project.wsgi:application
pythonpath=%(base)/dj_prj/test_project_venv/test_project/test_project/
http = :8000
master = true
processes = 5
# plugin = python
wsgi-file = %(base)/dj_prj/test_project_venv/test_project/test_project/wsgi.py
touch-reload = %(wsgi-file)
static-map=/static=%(base)/dj_stc/test_project/
app = wsgi
Here’s the content of the uwsgi log.
*** Starting uWSGI 2.0.19.1 (64bit) on [Fri Aug 14 03:24:04 2020] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-39) on 09 August 2020 17:57:54
os: Linux-3.10.0-1127.18.2.el7.x86_64 #1 SMP Sun Jul 26 15:27:06 UTC 2020
nodename: bebhionn.uberspace.de
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 20
current working directory: /
detected binary path: /home/devspiff/.local/bin/uwsgi
your processes number limit is 103763
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)
*** starting uWSGI Emperor ***
Python version: 3.8.3 (default, May 14 2020, 12:59:20) [GCC 8.3.1 20190311 (Red Hat 8.3.1-3)]
*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from test_project.ini
[uwsgi-static] added mapping for /static => /home/devspiff/dj_stc/test_project/
*** Starting uWSGI 2.0.19.1 (64bit) on [Fri Aug 14 03:24:04 2020] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-39) on 09 August 2020 17:57:54
os: Linux-3.10.0-1127.18.2.el7.x86_64 #1 SMP Sun Jul 26 15:27:06 UTC 2020
nodename: bebhionn.uberspace.de
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 20
current working directory: /home/devspiff/uwsgi/apps-enabled
detected binary path: /home/devspiff/.local/bin/uwsgi
chdir() to /home/devspiff/dj_prj/test_project_venv/test_project/test_project
your processes number limit is 103763
your memory page size is 4096 bytes
detected max file descriptor number: 1024
building mime-types dictionary from file /etc/mime.types...1060 entry found
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:40730 (port auto-assigned) fd 3
Python version: 3.8.3 (default, May 14 2020, 12:59:20) [GCC 8.3.1 20190311 (Red Hat 8.3.1-3)]
PEP 405 virtualenv detected: /home/devspiff/dj_prj/test_project_venv/
Set PythonHome to /home/devspiff/dj_prj/test_project_venv/
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1eefed0
your mercy for graceful operations on workers is 60 seconds
*** Operational MODE: no-workers ***
spawned uWSGI master process (pid: 20143)
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xe90ab0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 437520 bytes (427 KB) for 5 cores
*** Operational MODE: preforking ***
added /home/devspiff/dj_prj/test_project_venv/test_project/test_project/ to pythonpath.
ModuleNotFoundError: No module named 'test_project'
unable to load app 0 (mountpoint='') (callable not found or import error)
Traceback (most recent call last):
File "/home/devspiff/dj_prj/test_project_venv/test_project/test_project/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: 20145)
Fri Aug 14 03:24:04 2020 - [emperor] vassal test_project.ini has been spawned
spawned uWSGI worker 1 (pid: 20146, cores: 1)
spawned uWSGI worker 2 (pid: 20147, cores: 1)
spawned uWSGI worker 3 (pid: 20148, cores: 1)
spawned uWSGI worker 4 (pid: 20149, cores: 1)
spawned uWSGI worker 5 (pid: 20150, cores: 1)
spawned uWSGI http 1 (pid: 20151)
Fri Aug 14 03:24:04 2020 - [emperor] vassal test_project.ini is ready to accept requests
So the above mentioned Python 3.8.3 is the Python version that I used to create the venv. With my hoster in the shell, I have to use commands like “python3.8 -m venv /path/to/new/virtual/environment” as the standard python command is linked to Python 2.7.5. Now here is a strange behaviour I noticed. I used pip3.8 to install django. Django is now installed with python3.8. When I open a python3.8 shell and import django, it’s fine. When I open a python shell (2.7.5.) and import django, it is not installed. When I run “pip install django” (2.7.5) it says the requirement is met already.
Googling the error message that I got, I found a stackoverflow thread that suggested, that the Python version of uwsgi and the one of the venv have to be the same.
That makes no sense to me. I tried adding the path to the virtual environment to my pythonpath, but it did not help. Any suggestions would be appreciated. My knowledge about linux is very limited. It seems that this might be an access rights problem, but I’m in over my head.