You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason uWSGI packaged by pyuwsgi is apparently not able to find the correct Python: it uses the system-default Python instead of the virtual environment. This is shown as "ModuleNotFoundError: No module named 'pyuwsgi'" error when reloading uWSGI.
May 09 11:26:30 devel uwsgi[225420]: [uWSGI] getting INI configuration from uwsgi.ini
May 09 11:26:30 devel uwsgi[225420]: *** Starting uWSGI 2.0.23 (64bit) on [Thu May 9 11:26:30 2024] ***
May 09 11:26:30 devel uwsgi[225420]: compiled with version: 10.2.1 20210130 (Red Hat 10.2.1-11) on 10 January 2024 21:25:28
May 09 11:26:30 devel uwsgi[225420]: os: Linux-6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01)
May 09 11:26:30 devel uwsgi[225420]: current working directory: /home/markku/devel/django-test-with-pyuwsgi
May 09 11:26:30 devel uwsgi[225420]: detected binary path: /usr/bin/python3.11
May 09 11:26:30 devel uwsgi[225420]: chdir() to testproject
May 09 11:26:30 devel systemd[1]: Started testproject.service - Testproject uWSGI Service.
Test the Django project:
$ curl -s localhost:8001 | grep success
<title>The install worked successfully! Congratulations!</title>
<h1>The install worked successfully! Congratulations!</h1>
Then, send SIGTERM to the service with "sudo kill 225420" (using the correct PID) and see journal log again:
May 09 11:29:08 devel uwsgi[225420]: ...brutally killing workers...
May 09 11:29:08 devel systemd[1]: Stopping testproject.service - Testproject uWSGI Service...
May 09 11:29:09 devel uwsgi[225420]: worker 1 buried after 1 seconds
May 09 11:29:09 devel uwsgi[225420]: binary reloading uWSGI...
May 09 11:29:09 devel uwsgi[225420]: chdir() to /home/markku/devel/django-test-with-pyuwsgi
May 09 11:29:09 devel uwsgi[225420]: closing all non-uwsgi socket fds > 2 (max_fd = 1024)...
May 09 11:29:09 devel uwsgi[225420]: found fd 4 mapped to socket 0 (127.0.0.1:8001)
May 09 11:29:09 devel uwsgi[225420]: running /usr/bin/python3.11
May 09 11:29:09 devel uwsgi[225420]: Traceback (most recent call last):
May 09 11:29:09 devel uwsgi[225420]: File "/home/markku/devel/django-test-with-pyuwsgi/venv/bin/uwsgi", line 5, in <module>
May 09 11:29:09 devel uwsgi[225420]: from pyuwsgi import run
May 09 11:29:09 devel uwsgi[225420]: ModuleNotFoundError: No module named 'pyuwsgi'
May 09 11:29:09 devel systemd[1]: testproject.service: Main process exited, code=exited, status=1/FAILURE
May 09 11:29:09 devel systemd[1]: testproject.service: Failed with result 'exit-code'.
May 09 11:29:09 devel systemd[1]: Stopped testproject.service - Testproject uWSGI Service.
(Yes, "reloading" is expected as uWSGI by default considers SIGTERM as a reload signal, not terminate signal.)
= ModuleNotFoundError: No module named 'pyuwsgi', reload is not successful.
The text was updated successfully, but these errors were encountered:
markkuleinio
changed the title
ModuleNotFoundError: No module named 'pyuwsgi'
ModuleNotFoundError: No module named 'pyuwsgi' (when reloading)
May 9, 2024
For some reason uWSGI packaged by
pyuwsgi
is apparently not able to find the correct Python: it uses the system-default Python instead of the virtual environment. This is shown as "ModuleNotFoundError: No module named 'pyuwsgi'" error when reloading uWSGI.Is there something that I'm doing incorrectly?
Steps to reproduce:
Create
uwsgi.ini
:Create
/etc/systemd/system/testproject.service
:See the output (abbreviated):
Test the Django project:
Then, send SIGTERM to the service with "sudo kill 225420" (using the correct PID) and see journal log again:
(Yes, "reloading" is expected as uWSGI by default considers SIGTERM as a reload signal, not terminate signal.)
= ModuleNotFoundError: No module named 'pyuwsgi', reload is not successful.
Note the logs above:
even though uWSGI was installed and started successfully in the virtual environment.
About
pyuwsgi
vsuwsgi
:If
pyuwsgi
is replaced byuwsgi
(currentlyuWSGI==2.0.25.1
), the path to the uWSGI binary is correctly found and reload is working:The text was updated successfully, but these errors were encountered: