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
[uWSGI] getting INI configuration from uwsgi.ini
2025-02-17 11:50 - *** Starting uWSGI 2.0.28 (64bit) on [Mon Feb 17 11:50:52 2025] ***
2025-02-17 11:50 - compiled with version: 12.2.0 on 17 February 2025 03:28:29
2025-02-17 11:50 - os: Linux-6.1.0-31-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.128-1 (2025-02-07)
2025-02-17 11:50 - nodename: bridge
2025-02-17 11:50 - machine: x86_64
2025-02-17 11:50 - clock source: unix
2025-02-17 11:50 - pcre jit enabled
2025-02-17 11:50 - detected number of CPU cores: 2
2025-02-17 11:50 - current working directory: /data/website
2025-02-17 11:50 - writing pidfile to /dev/shm/website.pid
2025-02-17 11:50 - detected binary path: /data/website/python-3.12.9/bin/uwsgi
2025-02-17 11:50 - setgid() to 1002
2025-02-17 11:50 - setuid() to 1002
2025-02-17 11:50 - chdir() to /data/website/
2025-02-17 11:50 - your processes number limit is 6750
2025-02-17 11:50 - your memory page size is 4096 bytes
2025-02-17 11:50 - *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
2025-02-17 11:50 - detected max file descriptor number: 65535
2025-02-17 11:50 - lock engine: pthread robust mutexes
2025-02-17 11:50 - thunder lock: enabled
2025-02-17 11:50 - uwsgi socket 0 bound to UNIX address /dev/shm/website.socket fd 3
2025-02-17 11:50 - Python version: 3.12.9 (main, Feb 15 2025, 13:28:13) [GCC 12.2.0]
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = '.:.:'
program name = '/data/website/python-3.12.9/bin/uwsgi'
isolated = 0
environment = 1
user site = 1
safe_path = 0
import site = 1
is in build tree = 0
stdlib dir = '/opt/python-3.12.9/lib/python3.12'
sys._base_executable = '/root/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/bin/uwsgi'
sys.base_prefix = '/opt/python-3.12.9'
sys.base_exec_prefix = '/opt/python-3.12.9'
sys.platlibdir = 'lib'
sys.executable = '/data/website/python-3.12.9/bin/uwsgi'
sys.prefix = '/opt/python-3.12.9'
sys.exec_prefix = '/opt/python-3.12.9'
sys.path = [
'/data/website',
'/data/website',
'/data/website',
'/opt/python-3.12.9/lib/python312.zip',
'/opt/python-3.12.9/lib/python3.12',
'/opt/python-3.12.9/lib/python3.12/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007ff1e2713040 (most recent call first):
<no Python frame>
2025-02-17 11:50 - VACUUM: unix socket /dev/shm/website.socket removed.
Note this error:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
I tried compiling and installing Python 3.12.9 from source without any issues, everything went well. However, when installing via uv python install, I encountered the above error, and the same happens with other versions of Python. And only uwsgi had this issue, the other libraries are all fine.
The text was updated successfully, but these errors were encountered:
The default installation path for uv python install is ~/.local/share/uv/python/*
Run uwsgi using the root account and specified --user nobody
When these two conditions are met simultaneously, a ModuleNotFoundError occurs.
The master process of uwsgi runs as root, so it can read the Python built-in library normally. However, when starting the worker process, it dynamically loads modules and does not have permission to access /root/.local/share/uv/python/*, leading to a ModuleNotFoundError.
The same issue occurs with gunicorn. When gunicorn starts the worker process, it throws an exception just like uwsgi does.
If I compile Python from source and the installation path is /opt/python/*, the nobody user has access permission, so it goes well.
Solution:
Set the environment variable UV_PYTHON_INSTALL_DIR to install Python in a directory outside of /root, allowing normal users to have access permission.
Note this error:
I tried compiling and installing Python 3.12.9 from source without any issues, everything went well. However, when installing via
uv python install
, I encountered the above error, and the same happens with other versions of Python. And only uwsgi had this issue, the other libraries are all fine.The text was updated successfully, but these errors were encountered: