我很難用python3.4和virtualenv。將PythonHome設置爲/ var/www/virtualenvs/myenv/ImportError:沒有模塊名爲site
項目在本地運行良好,但一旦部署,我得到502壞網關。我看着uwsgi日誌,我看到了這一點:
uwsgi socket 0 bound to UNIX address /var/www/mysite/live.sock fd 6
Python version: 2.7.9 (default, Mar 1 2015, 13:01:26) [GCC 4.9.2]
Set PythonHome to /var/www/virtualenvs/myenv/
ImportError: No module named site
我uwsgi設置爲:
[uwsgi]
socket = /var/www/mysite/live.sock
chdir = /var/www/mysite
module = project.wsgi:application
virtualenv = /var/www/virtualenvs/myenv/
buffer-size = 4096
processes = 40
home = /var/www/virtualenvs/myenv/
plugin = python34
env = DJANGO_SETTINGS_MODULE=project.settings
enable-threads = True
single-interpreter = True
uid = www-data
gid = www-data
vacuum = True
disable-logging = true
logger = file:/var/www/mysite/log/uwsgi_err.log
我失去了關於python3的東西嗎?高度讚賞任何幫助
看起來像你的服務器上運行的是錯誤版本的Python:'Python版本:2.7.9' – Pyrce
@Pyrce該死的你是對的..但任何想法如何解決這個問題? – doniyor
我猜你的默認python和/或你設置的虛擬env是錯誤的版本。你可以嘗試別名python =/usr/local/bin/python3.4你的python爲啓動服務的用戶使用,或者爲你的服務器改變默認的'python'(如果其他應用程序依賴於2.7,可能會有風險) )。你一定要用2.7來燒燬你的virtualenv設置並重建它。 – Pyrce