uWSGI致命Python错误:Py_Initialize:无法获取语言环境编码

时间:2013-12-29 16:55:55

标签: python uwsgi

我至少看过3个关于这个问题的问题。

  1. Virtualenv(Python 3.2)
  2. 这个环境中的Django项目
  3. uWSGI
  4. 但我在uWSGI设置文件中有plugins = python3,没关系! 服务器已启动,一切正常 ...
    重启服务器 - 一切都还在运行......
    重新加载服务器(或touch reload-file),您遇到此错误:

    Fatal Python error: Py_Initialize: Unable to get the locale encoding
    ImportError: No module named encodings
    

    更多......我在另一个环境中有另一个项目,touch reload-file为它工作 任何建议为什么会发生这种情况?

    PS:我试图创建一个新的virtualenv

    日志:

    service uwsgi restart之后:

    ...
    Sun Dec 29 22:57:21 2013 - detected max file descriptor number: 1024
    Sun Dec 29 22:57:21 2013 - lock engine: pthread robust mutexes
    Sun Dec 29 22:57:21 2013 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/test/socket fd 3
    Sun Dec 29 22:52:59 2013 - uwsgi socket 1 bound to TCP address 127.0.0.1:3045 fd 5
    Sun Dec 29 22:52:59 2013 - Python version: 3.2.3 (default, Sep 25 2013, 19:38:45)  [GCC 4.7.2]
    Sun Dec 29 22:52:59 2013 - Set PythonHome to /pyenvs/test/
    Sun Dec 29 22:52:59 2013 - Python main interpreter initialized at 0x688cc0
    Sun Dec 29 22:52:59 2013 - threads support enabled
    Sun Dec 29 22:52:59 2013 - your server socket listen backlog is limited to 10000 connections
    Sun Dec 29 22:52:59 2013 - *** Operational MODE: preforking ***
    Sun Dec 29 22:52:59 2013 - WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x688cc0 pid: 1619 (default app)
    Sun Dec 29 22:52:59 2013 - *** uWSGI is running in multiple interpreter mode ***
    Sun Dec 29 22:52:59 2013 - spawned uWSGI master process (pid: 1619)
    Sun Dec 29 22:52:59 2013 - spawned uWSGI worker 1 (pid: 1628, cores: 1)
    Sun Dec 29 22:52:59 2013 - spawned uWSGI worker 2 (pid: 1629, cores: 1)
    

    service uwsgi reload之后:

    Sun Dec 29 22:55:31 2013 - *** Starting uWSGI 1.2.3-debian (64bit) on [Sun Dec 29 22:55:31 2013] ***
    ...
    Sun Dec 29 22:55:31 2013 - detected max file descriptor number: 1024
    Sun Dec 29 22:55:31 2013 - lock engine: pthread robust mutexes
    Sun Dec 29 22:55:31 2013 - uwsgi socket 0 inherited UNIX address /run/uwsgi/app/test/socket fd 3
    Sun Dec 29 22:55:31 2013 - uwsgi socket 1 inherited INET address 127.0.0.1:3045 fd 5
    Sun Dec 29 22:55:31 2013 - Python version: 3.2.3 (default, Sep 25 2013, 19:38:45)  [GCC 4.7.2]
    Sun Dec 29 22:55:31 2013 - Set PythonHome to /pyenvs/test/
    Fatal Python error: Py_Initialize: Unable to get the locale encoding
    ImportError: No module named encodings
    

    更新1

    绝对是虚拟环境。复制我的旧VEnv并使用不会导致此问题 仍然不知道为什么新创建的不起作用 仅复制python可执行文件无效。

1 个答案:

答案 0 :(得分:1)

我不知道发生了什么事,因为我做了很多事情:

  1. 系统升级
  2. 新的python环境
  3. Python版本3.3,而不是3.2
  4. uwsgi 1.2.4系统包(也许这有帮助)
    或者更好地在您的VE中使用pip install uwsgi并使用supervisord
  5. 运行您需要的内容

    现在它正在运作。谢谢罗伯托。