2013-08-27 47 views
2

我有uWSGI全局安裝,它與Django的Python 3.3的virtualenv運行就好了。但是現在我想嘗試使用Python 2.7運行另一個uWSGI實例。我在Python 2.7的virtualenv中爲家設置了選項,但它使用的python版本仍然是3.3版本。uWSGI用於運行Python 2和Python3與Django

目前我有這個設置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 

回答

2

你uWSGI二進制與特定libpython(3.3)連結。你必須建立uWSGI的第二個副本python2.7或者使用一個模塊化的構建:

(從源代碼目錄)

python3 uwsgiconfig.py --build nolang

python3 uwsgiconfig.py - 插件插件/蟒蛇nolang python33

python2 uwsgiconfig.py --plugin插件/蟒蛇nolang python27

你會用 'uwsgi' 二進制和 'python33_plugin.so' 和 'python27_plugin.so'

+0

所以我必須從源代碼編譯它?這不會影響系統範圍的uwsgi嗎?感謝你的回答。 :) –

+0

沒有生成的二進制文件和插件將被構建在源目錄中 – roberto