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)

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?


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

  • But what if a virtualenv is required to run the app?
    – vmonteco
    Feb 24 '17 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.