uWSGI Fails with No module named encoding Error

匿名 (未验证) 提交于 2019-12-03 00:46:02

问题:

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 python32is 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:

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:

  1. sudo pip uninstall uwsgi

  2. something goes wrong when i run sudo pip install uwsgi, and run this first:

    sudo apt-get install python-dev

  3. (sudo)pip install uwsgi



回答4:

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.



回答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.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!