1

I'm having serious trouble to start uwsgi in django project with nginx. I even tried to run plugins=python36 but still failed. I checked uWSGI Fails with No module named encoding Error but doesn't help me. I still have no idea how to fix the ModuleNotFoundError: No module named 'encodings'. Could you please advise and help me out? Thanks!!

Here's the versions info:

  • Python 3.6.9
  • uwsgi 2.0.18
  • nginx version: nginx/1.14.0 (Ubuntu)
  • /usr/local/bin/uwsgi

I got the following error when running sudo uwsgi --ini /usr/share/nginx/html/portal/portal_uwsgi.ini

[uWSGI] getting INI configuration from /usr/share/nginx/html/portal/portal_uwsgi.ini
open("./python3_plugin.so"): No such file or directory [core/utils.c line 3724]
!!! UNABLE to load uWSGI plugin: ./python3_plugin.so: cannot open shared object file: No such file or directory !!!
*** Starting uWSGI 2.0.18 (64bit) on [Thu Jun 18 22:51:54 2020] ***
compiled with version: 7.5.0 on 11 June 2020 23:01:20
os: Linux-5.3.0-59-generic #53~18.04.1-Ubuntu SMP Thu Jun 4 14:58:26 UTC 2020
machine: x86_64
clock source: unix
detected number of CPU cores: 4
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /usr/share/nginx/html/portal
your processes number limit is 63773
your memory page size is 4096 bytes
 *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.9 (default, Apr 18 2020, 01:56:04)  [GCC 8.4.0]
Set PythonHome to /usr/share/nginx/html/portal
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f962e59e640 (most recent call first):
Aborted

Here's the /usr/share/nginx/html/portal/portal_uwsgi.ini

[uwsgi]

# Django-related settings
# the base directory (full path)
chdir           = /usr/share/nginx/html/portal
# Django's wsgi file
module          = config.wsgi
# the virtualenv (full path)
home            = /usr/share/nginx/html/portal

# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 10
# the socket (use the full path to be safe
socket          = /tmp/uwsgi.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 666
# clear environment on exit
vacuum          = true
# Reload worker to avoid memory leak
max-requests    = 5000
# Recycle worker if a request to it takes longer than specified seconds
harakiri        = 90

plugins = python3
Jack
  • 67
  • 3
  • Have you tried setting the Python home directory (PYTHONHOME). Not finding the encoding module mostly means that it can't find the Lib dir – HelloWorld Jun 19 '20 at 13:45
  • yes I did export PYTHON=/usr/bin/python3.6, but still failed – Jack Jun 19 '20 at 16:07
  • `PYTHON` != `PYTHONHOME` https://docs.python.org/3/using/cmdline.html#envvar-PYTHONHOME – HelloWorld Jun 19 '20 at 17:57
  • I did the following but still the same. I'm confused why the error says ```Set PythonHome to /usr/share/nginx/html/portal``` because this is not python3 home location. which python3 /usr/bin/python3 ```export PYTHONHOME=/usr/bin/python3``` – Jack Jun 22 '20 at 05:06
  • And I tried both inside virtualenv and outside, and I got the same uwsgi error. Any suggestions? Please help – Jack Jun 22 '20 at 05:19

0 Answers0