Forums

No module named 'encodings'; segmentation fault

I'm coming back to a web project after some time, and after fixing the DNS, im facing issues with Python. I'm not very familiar with Python, it was a miracle I got the project working initially.

Now, I get 502 errors, with the server log showing the error below:

2025-02-02 22:39:27 Current thread 0x 2025-02-02 22:39:27 00007db72a538780 2025-02-02 22:39:27 (most recent call first): 2025-02-02 22:39:27 !!! uWSGI process 1 got Segmentation Fault !!! 2025-02-02 22:39:27 *** backtrace of 1 ***#012/usr/local/bin/uwsgi(uwsgi_backtrace+0x2e) [0x5d92af2409be]#012/usr/local/bin/uwsgi(uwsgi_segfault+0x27) [0x5d92af240da7]#012/lib/x86_64-linux-gnu/libc.so.6(+0x43090) [0x7db72c44f090]#012/lib/x86_64-linux-gnu/libc.so.6(abort+0x213) [0x7db72c42e941]#012/usr/local/lib/libpython3.7m.so.1.0(+0x6d80b) [0x7db72a1c980b]#012/usr/local/lib/libpython3.7m.so.1.0(+0x196f53) [0x7db72a2f2f53]#012/usr/local/lib/libpython3.7m.so.1.0(Py_InitializeEx+0xd0) [0x7db72a2f3c90]#012/usr/lib/uwsgi/python37_plugin.so(uwsgi_python_init+0x144) [0x7db72a4bb0c4]#012/usr/local/bin/uwsgi(uwsgi_start+0x5af) [0x5d92af24201f]#012/usr/local/bin/uwsgi(uwsgi_setup+0x127c) [0x5d92af2442cc]#012/usr/local/bin/uwsgi(main+0xf) [0x5d92af1efb3f]#012/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7db72c430083]#012/usr/local/bin/uwsgi(_start+0x2e) [0x5d92af1efb7e]#012*** end of backtrace *** 2025-02-02 22:39:27 VACUUM: unix socket /var/sockets/www.liverpoolgecko.co.uk/socket removed. 2025-02-02 22:41:15 *** Starting uWSGI 2.0.20 (64bit) on [Sun Feb 2 22:41:15 2025] *** 2025-02-02 22:41:15 compiled with version: 9.4.0 on 22 July 2022 18:35:26 2025-02-02 22:41:15 os: Linux-6.5.0-1022-aws #22~22.04.1-Ubuntu SMP Fri Jun 14 16:31:00 UTC 2024 2025-02-02 22:41:15 nodename: blue-liveweb30 2025-02-02 22:41:15 machine: x86_64 2025-02-02 22:41:15 clock source: unix 2025-02-02 22:41:15 pcre jit disabled 2025-02-02 22:41:15 detected number of CPU cores: 4 2025-02-02 22:41:15 current working directory: /home/pablopython 2025-02-02 22:41:15 detected binary path: /usr/local/bin/uwsgi 2025-02-02 22:41:15 *** dumping internal routing table *** 2025-02-02 22:41:15 [rule: 0] subject: path_info regexp: \.svgz$ action: addheader:Content-Encoding:gzip 2025-02-02 22:41:15 *** end of the internal routing table *** 2025-02-02 22:41:15 chdir() to /home/pablopython/ 2025-02-02 22:41:15 your processes number limit is 512 2025-02-02 22:41:15 your memory page size is 4096 bytes 2025-02-02 22:41:15 detected max file descriptor number: 123456 2025-02-02 22:41:15 building mime-types dictionary from file /etc/mime.types... 2025-02-02 22:41:15 567 entry found 2025-02-02 22:41:15 lock engine: pthread robust mutexes 2025-02-02 22:41:15 thunder lock: disabled (you can enable it with --thunder-lock) 2025-02-02 22:41:15 uwsgi socket 0 bound to UNIX address /var/sockets/www.liverpoolgecko.co.uk/socket fd 3 2025-02-02 22:41:15 Python version: 3.7.13 (default, Jul 22 2022, 17:01:12) [GCC 9.4.0] 2025-02-02 22:41:15 Set PythonHome to /home/pablopython/.virtualenvs/threepointseven 2025-02-02 22:41:15 Fatal Python error: 2025-02-02 22:41:15 initfsencoding 2025-02-02 22:41:15 : 2025-02-02 22:41:15 Unable to get the locale encoding 2025-02-02 22:41:15 2025-02-02 22:41:15 ModuleNotFoundError 2025-02-02 22:41:15 : 2025-02-02 22:41:15 No module named 'encodings'

I have tried reinstalling the python packages in the virtualenv, and reloading the app multiple times, to no avail.

Any help is much appreciated

Looks like it's related to system image change. Rebuild your virtual environment and it should work. See multiple emails about system image change that you got from us.

I ended up going through the process of making a new 3.10 venv, and that looks like it's worked

Glad to hear you got that working!