Python – uWSGI and Python on Arch Linux, encoding failure

arch-linuxpythonuwsgi

I am running an Arch Linux box and have setup a Python 3.4 virtualenv.

I have a uwsgi vassal being run by the emperor, which specifies the following ini: (some snipped for brevity)

[uwsgi]
virtualenv = /opt/lib/virtualenvs/bartek
socket = /tmp/bartek.sock
module = app
callable = app
plugins = python

When I run this and view the uwsgi log file, I consistently get this:

uwsgi socket 0 bound to UNIX address /tmp/bartek.sock fd 3
Python version: 3.4.1 (default, May 19 2014, 17:23:49)  [GCC 4.9.0 20140507 (prerelease)]
Set PythonHome to /opt/lib/virtualenvs/bartek
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

This seems to be potentially related to the virtualenv? When I remove virtualenv from uwsgi config, it fails on missing packages instead of complaining about this encoding. I'd prefer to keep using a virtualenv, though!

Any ideas?

Best Answer

I had the same problem, and I guess this is caused by the virtualenv parameter, when I changed the virtualenv to /, everything is OK.