简体   繁体   English

没有virtualenv(ImportError)无法启动uWSGI服务器

[英]Can't start uWSGI server without virtualenv (ImportError)

I'm running django+nginx+uwsgi. 我正在运行django + nginx + uwsgi。 For some reason I cannot start uWSGI without setting home option, pointing to virtual environment. 出于某种原因,我无法在没有设置home选项的情况下启动uWSGI,指向虚拟环境。 Whenever I start uWSGI without it, it says that it cannot find module django.core.wsgi, like if python path was empty (but django 1.4 is installed system-wide). 每当我启动没有它的uWSGI时,它就说它找不到模块django.core.wsgi,就好像python路径是空的(但是系统范围内安装了django 1.4)。

How can i fix it? 我该如何解决?

Since I hit my head on this problem too, let's write an answer for all. 既然我也想到了这个问题,让我们为所有人写一个答案。 :) The problem is that, when starting in emperor mode (system wide), the uwsgi master process can't (or won't) load the correct environ for python (PYTHONPATH). :)问题是,当以emperor模式(系统范围)启动时,uwsgi主进程不能(或不会)为python(PYTHONPATH)加载正确的环境。 Using virtualenv you specify the environ. 使用virtualenv指定环境。 Without it you need to set the pythonpath variable, even multiple times pointing to the system-wide python paths. 没有它你需要设置pythonpath变量,甚至多次指向系统范围的python路径。

Just as an example, for my system it's: 举个例子,对我的系统来说:

pythonpath = /usr/local/lib/python2.7/dist-packages
pythonpath = /usr/lib/python2.7

(using the ini syntax) (使用ini语法)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM