2014-03-05 29 views
7

當試圖運行我的燒瓶應用程序,我得到的錯誤:運行uwsgi用的virtualenv和瓶

uwsgi no module named site 

我創建一個配置文件作爲這樣的:

[uwsgi] 
socket = 127.0.0.1:8000 
processes = 4 
virtualenv = /var/www/test/venv 
chdir = /var/www/test 
module = run 
callable = manager 
logto = var/www/uwsgi.log 

我run.py的位置是/var/www/test/run.py用下面的代碼:

from flask.ext.migrate import Migrate, MigrateCommand 
from flask.ext.script import Manager 
from app import app, db 

if __name__ == "__main__": 
    migrate = Migrate(app, db) 
    manager = Manager(app) 
    manager.add_command('db', MigrateCommand) 
    manager.run() 

誰能幫我明白的地方我已經錯了認罪SE?我正在運行一個系統範圍的UWSGI。

編輯

我安裝uwsgi和使用的virtualenv PIP和我有以下版本:

  • uWSGI == 2.0.2
  • 的virtualenv == 1.11.4

我的系統寬python版本(和我venv裏面的一個版本)是:Python 2.7.3

+2

通常這個錯誤是你的virtualenv已經爲不同的python版本構建的標誌,而不是uWSGI使用的那個。 – roberto

+0

非常感謝你的幫助@roberto。我在我的問題中添加了更多信息,這是否有助於解決問題? – Jimmy

+0

@roberto人告訴我使用無站點選項,但這看起來像是一個閃避 – Jimmy

回答

2

你不想使用app.run()(或manager.run())和uwsgi在同一時間,這是因爲:

所以,你只需要正確設置uwsgi,這樣的事情應該工作:

app-name = test 

pidfile = /run/uwsgi/%(app-name)/pid 
socket  = /run/uwsgi/%(app-name)/socket 

logto  = /var/log/uwsgi/%(app-name).log 
log-date = true 

processes = 4 
plugins = http,python 

base  = /srv/www/%(app-name) 
home  = %(base)/venv # http://uwsgi-docs.readthedocs.org/en/latest/Options.html#home-virtualenv-venv-pyhome 
pythonpath = %(base)/venv # http://uwsgi-docs.readthedocs.org/en/latest/Options.html#pythonpath-python-path-pp 

module  = app 
callable = app 

chdir  = %(base)