Answer the question
In order to leave comments, you need to log in
Python3+uwsgi on Ubuntu 16.04. No module named 'encodings' - how to find out what's wrong?
Ubuntu 16.04, Python3, virtualenvwrapper, uwsgi. Python and uwsgi are standard system ones.
Error when starting the uwsgi service, key lines in the log -
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
home=/root/.virtualenvs/vek/bin/python
# cat /etc/uwsgi/apps-enabled/vek.ini
[uwsgi]
plugins=python3
chdir=/srv/vek/django
module=vek.wsgi:application
home=/root/.virtualenvs/vek/bin/python
# apt-get install uwsgi-plugin-python3
Reading package lists... Done
Building dependency tree
Reading state information... Done
uwsgi-plugin-python3 is already the newest version (2.0.12-5ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
# cat /var/log/uwsgi/app/vek.log
...
Thu Jun 23 17:12:52 2016 - *** Starting uWSGI 2.0.12-debian (64bit) on [Thu Jun 23 17:12:51 2016] ***
Thu Jun 23 17:12:52 2016 - compiled with version: 5.3.1 20160412 on 13 April 2016 08:36:06
Thu Jun 23 17:12:52 2016 - os: Linux-4.4.0-24-generic #43-Ubuntu SMP Wed Jun 8 19:27:37 UTC 2016
Thu Jun 23 17:12:52 2016 - nodename: vek-dverey.ru
Thu Jun 23 17:12:52 2016 - machine: x86_64
Thu Jun 23 17:12:52 2016 - clock source: unix
Thu Jun 23 17:12:52 2016 - pcre jit disabled
Thu Jun 23 17:12:52 2016 - detected number of CPU cores: 1
Thu Jun 23 17:12:52 2016 - current working directory: /
Thu Jun 23 17:12:52 2016 - writing pidfile to /run/uwsgi/app/vek/pid
Thu Jun 23 17:12:52 2016 - detected binary path: /usr/bin/uwsgi-core
Thu Jun 23 17:12:52 2016 - setgid() to 33
Thu Jun 23 17:12:52 2016 - setuid() to 33
Thu Jun 23 17:12:52 2016 - chdir() to /srv/vek/django
Thu Jun 23 17:12:52 2016 - your processes number limit is 3912
Thu Jun 23 17:12:52 2016 - your memory page size is 4096 bytes
Thu Jun 23 17:12:52 2016 - detected max file descriptor number: 1024
Thu Jun 23 17:12:52 2016 - lock engine: pthread robust mutexes
Thu Jun 23 17:12:52 2016 - thunder lock: disabled (you can enable it with --thunder-lock)
Thu Jun 23 17:12:52 2016 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/vek/socket fd 3
Thu Jun 23 17:12:52 2016 - Python version: 3.5.1+ (default, Mar 30 2016, 22:46:26) [GCC 5.3.1 20160330]
Thu Jun 23 17:12:52 2016 - Set PythonHome to /root/.virtualenvs/vek/bin/python
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f0abc3b7780 (most recent call first):
# /root/.virtualenvs/vek/bin/python
Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import encodings
>>> encodings
<module 'encodings' from '/root/.virtualenvs/vek/lib/python3.5/encodings/__init__.py'>
>>>
# uwsgi<TAB key>
uwsgi uwsgi-core uwsgi_python3 uwsgi_python35
Answer the question
In order to leave comments, you need to log in
Get a user
Get him a directory in / home
Put everything there
In uwsgi specify which user you need to run
To use plugins=python3
you need to put uwsgi-plugin-python3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question