问题
I am trying to setup uWSGI with Pyramid, but I am getting this error, when attempting uwsgi --ini-paste development.ini
Python version: 3.2.3
Error message:
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 3
Python version: 3.2.3 (default, Oct 19 2012, 20:08:46) [GCC 4.6.3]
Set PythonHome to /root/path/to/virtualenv
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named encodings
Here is what I have in development.ini
[uwsgi]
socket = /tmp/uwsgi.sock
master = true
processes = 4
harakiri = 60
harakiri-verbose = true
limit-post = 65536
post-buffering = 8192
daemonize = ./uwsgi.log
pidfile = ./pid_5000.pid
listen = 256
max-requests = 1000
reload-on-as = 128
reload-on-rss = 96
no-orphans = true
log-slow = true
virtualenv = /root/path/to/virtualenv
I suppose I have checked everything possible, including the following
echo LANG:$LANG LC_CTYPE:$LC_CTYPE
LANG:en_US.UTF-8 LC_CTYPE:
I am using virtualenv and uWSGI was installed while the environment was active. I have also checked that my virtual environment's lib has a package named encoding (pointing to my main python3.2 installation)
I have also checked this answer and this
I had previously installed uWSGI when my virtualenv was not active, but then I installed it properly and removed the executable and py files from previous installation.
Is there a way to get detailed logs, please let me know if there is. Thanks in advance
回答1:
in my case it was basically because I used python 2.7 as main interpreter, and uwsgi choose pyhon3 plugin. You might need to force it using:
plugins=python32
where python32
is appropriate name for your pythhon3 plugin.
Have you checked this: uwsgi python3 plugin doesn't work?
回答2:
Check that
virtualenv = /root/path/to/virtualenv
points to the right path. I solved my error by fixing this mistyped path.
回答3:
Just had the same problem. What I realized afterwards was that I installed uwsgi with pip install uwsgi
in the virtualenv. Once I left the virtualenv, I installed uwsgi on the local system with
pip3 install uwsgi
(notice I wrote pip instead of pip3). So I uninstalled with pip3 uninstall uwsgi
and I repeated with pip install uwsgi
. Worked like a Charm.
回答4:
I also met this problem today, and I tried to set plugins=python34
, but it did not work on Ubuntu 14.04 and Python 3.4.3
This is what I did to fix it:
sudo pip uninstall uwsgi
something goes wrong when i run
sudo pip install uwsgi
, and run this first:sudo apt-get install python-dev
(sudo)pip install uwsgi
回答5:
Run uwsgi command (with your options) just like the following line:
/<path-to-your-virtualenv-bin>/uwsgi --http :8008 --module project.wsgi --venv /<path-to-your-virtualenv> --chdir /<path-to-your-project>
You will find the issues.
Did you miss your module param?
回答6:
I encountered a similar error message, but with a python version variation:
Python version: 3.4.3 (default, Nov 28 2017, 16:44:58) [GCC 4.8.4]
This came about from trying to use a python3.6 virtual environment, but uwsgi being setup for python3.4. I re-setup the virtual environment using python3.4 and all was well.
回答7:
Building upon Edward's answer, I instead reinstalled uWSGI
with pip3.6
instead of pip3
, Python 3.4.8 being the default Python 3 on the server:
$ python3 --version
Python 3.4.8
来源:https://stackoverflow.com/questions/16272542/uwsgi-fails-with-no-module-named-encoding-error