问题描述
通常,我将使用virtualenv
和pip
来部署Web应用程序.对于Google App Engine,此操作不起作用,因为所有import
语句都是相对于应用程序目录的.
Usually I would use virtualenv
and pip
for deployment of web applications. With Google App Engine this doesn't work, because all import
statement are relative to directory of the application.
我看到的最常见的方法是简单地将包从site-packages
复制到应用程序的目录中.这涉及手工操作,并且容易出错.
The most common approach I saw was to simply copy the packages from site-packages
to the directory of the application. This involves manual work and is error-prone.
另一种方法是更改~/.pydisutils.cfg
中的install_lib
和install_scripts
,但这不允许我同时在主目录中使用pip
.
Another approach was to changes install_lib
and install_scripts
in ~/.pydisutils.cfg
, but this doesn't allow me to use pip
in my home directory simultaneously.
对此有什么建议吗?
推荐答案
似乎手动将virtualenv
添加到sys.path
可以为我解决此问题:
It seems manually adding the virtualenv
to sys.path
solves the problem for me at the moment:
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'dev.env/lib/python2.5/site-packages/'))
这篇关于Google App Engine上的Python Eggs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!