virtualenv macosX --no-site-package 被忽略
我在使用macOSX和virtualenv时遇到了一些问题。它似乎不管用--no-site-package这个选项。用同样的命令在Linux(archlinux)上就能正常工作。我的系统是macOSX 10.5,使用的是python 2.5。
curl -o virtualenv.py 'http://bitbucket.org/ianb/virtualenv/raw/tip/virtualenv.py
创建一个新的环境
python virtualenv.py --no-site-packages foo
New python executable in foo/bin/python
Installing setuptools...........................done.
激活这个环境
source foo/bin/activate
尝试在这个环境中安装一些东西。尽管使用了virtualenv,它还是会去找系统范围内的安装包。
easy_install cherrypy
Searching for cherrypy
Best match: CherryPy 3.1.2
Adding CherryPy 3.1.2 to easy-install.pth file
Using /Library/Python/2.5/site-packages
Processing dependencies for cherrypy
Finished processing dependencies for cherrypy
但是它找不到这个模块。
(foo)guidage-multimodal:~ tristram$ python
Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cherrypy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cherrypy
我尝试使用PIP,参考了这个链接:virtualenv --no-site-packages和pip仍然找到全局包?。不过在安装psycopg2时失败了(gcc有一些问题)。我还希望能有一个setup.py(来自distribute),可以完成整个工作。
更新 在macOS 10.6上,它按预期工作。可能是python 2.5太旧了,或者安装有问题,所以我放弃了,决定需要macOS 10.6……
1 个回答
1
这可能是因为你用的 easy_install 版本太旧了。建议你使用 pip 来安装:
easy_install pip
pip install virtualenv -U
virtualenv env
source env/bin/activate
pip -E env install cherrypy