2

我已经全局安装了 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
4

1 回答 1

3

Your uWSGI binary is linked with a specific libpython (the 3.3 one). You have to build a second copy of uWSGI for python2.7 or use a modular build:

(from source directory)

python3 uwsgiconfig.py --build nolang

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

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

you will end with a 'uwsgi' binary and 'python33_plugin.so' and 'python27_plugin.so'

于 2013-08-27T05:47:56.233 回答