【问题标题】:uWSGI for running Python 2 and Python3 with django使用 django 运行 Python 2 和 Python3 的 uWSGI
【发布时间】:2013-08-27 04:05:22
【问题描述】:

我已经全局安装了 uWSGI,它使用 Python 3.3 的 virtualenv 和 Django 运行就好了。但现在我想尝试使用 Python 2.7 运行另一个 uWSGI 实例。我在 Python 2.7 的 virtualenv 中设置了 home 选项,但它使用的 python 版本仍然是 3.3 版本。

目前我有 uWSGI 的这个设置:

 # Django-related settings
 # the base directory (full path)
 chdir           = /home/srvadmin/webapps2.7/project
 # Django's wsgi file
 module          = project.wsgi
 # the virtualenv (full path)
 home            = /home/srvadmin/py2.7

 # process-related settings
 # master
 master          = true
 # maximum number of worker processes
 processes       = 10
 # the socket (use the full path to be safe
 socket          = /tmp/mysite2.7.sock
 # ... with appropriate permissions - may be needed
 chmod-socket    = 666
 # clear environment on exit
 vacuum          = true

但我总是得到这个

uWSGI http bound on 0.0.0.0:1234 fd 4
spawned uWSGI http 1 (pid: 31507)
uwsgi socket 0 bound to TCP address 127.0.0.1:33896 (port auto-assigned) fd 3
Python version: 3.3.2 (default, May 16 2013, 18:35:00)  [GCC 4.6.3]
Set PythonHome to /home/srvadmin/py2.7/
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted

【问题讨论】:

    标签: python django uwsgi


    【解决方案1】:

    您的 uWSGI 二进制文件与特定的 libpython(3.3 版本)链接。您必须为 python2.7 构建第二个 uWSGI 副本或使用模块化构建:

    (来自源目录)

    python3 uwsgiconfig.py --build nolang

    python3 uwsgiconfig.py --plugin plugins/python nolang python33

    python2 uwsgiconfig.py --plugin plugins/python nolang python27

    您将以“uwsgi”二进制文件和“python33_plugin.so”和“python27_plugin.so”结束

    【讨论】:

    • 所以我必须从源代码编译它?这不会影响系统范围的uwsgi吧?感谢你的回答。 :)
    • 不会在源目录中构建生成的二进制文件和插件
    猜你喜欢
    • 2019-12-21
    • 2011-04-16
    • 2019-11-29
    • 1970-01-01
    • 2018-04-08
    • 1970-01-01
    • 2017-05-31
    • 2014-04-07
    • 2012-04-13
    相关资源
    最近更新 更多