Virtualenv 不使用全局包
请帮助诊断 virtualenv 问题。它想要下载并安装 numpy 和 lxml,而全局站点包中有符合版本要求的已安装版本。
$ virtualenv venv # not restricting access to site-packages
...
$ . venv/bin/activate
(venv)$ python -c 'import numpy; print numpy._version_; print numpy.__file__'
1.5.1
/usr/lib/pymodules/python2.7/numpy/_init_.pyc
(venv)$ grep numpy setup.py
'numpy>=1.5.1',
(venv)$ python setup.py develop
...
Searching for numpy==1.5.1 # Why exact ==1.5.1? Where is it from?
Reading http://pypi.python.org/simple/numpy/
Reading http://numpy.scipy.org
Reading http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103
Reading http://numeric.scipy.org
Best match: numpy 1.5.1
Downloading http://pypi.python.org/packages/source/n/numpy/numpy-1.5.1.tar.gz#md5=376ef150df41b5353944ab742145352d
版本:Ubuntu 11.04、Python 2.7.1+、virtualenv 1.4.9
更新:virtualenv 1.5.1 及更高版本按预期工作。还是很好奇到底出了什么问题。
Please help to diagnose virtualenv problem. It wants to download and install numpy and lxml, while there are installed versions in global site-packages that match version requirements.
$ virtualenv venv # not restricting access to site-packages
...
$ . venv/bin/activate
(venv)$ python -c 'import numpy; print numpy._version_; print numpy.__file__'
1.5.1
/usr/lib/pymodules/python2.7/numpy/_init_.pyc
(venv)$ grep numpy setup.py
'numpy>=1.5.1',
(venv)$ python setup.py develop
...
Searching for numpy==1.5.1 # Why exact ==1.5.1? Where is it from?
Reading http://pypi.python.org/simple/numpy/
Reading http://numpy.scipy.org
Reading http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103
Reading http://numeric.scipy.org
Best match: numpy 1.5.1
Downloading http://pypi.python.org/packages/source/n/numpy/numpy-1.5.1.tar.gz#md5=376ef150df41b5353944ab742145352d
Versions: Ubuntu 11.04, Python 2.7.1+, virtualenv 1.4.9
Upd: virtualenv 1.5.1 and newer works as expected. Still curious what was the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据提出这个问题的时间,我的答案无法解决OP所遇到的问题,但我遇到了类似的问题并提出了这个问题。我弄清楚了我的问题是什么,所以我将这个答案发布给后代和任何遇到此问题的其他人。
从 virtualenv 1.7 开始 --no-site-packages 成为默认行为。要使全局站点包可导入(这曾经是默认设置),您必须在创建 virtualenv 时使用选项 --system-site-packages。
Based on when this question was asked, my answer would not solve the issue the OP had, but I was having a similar problem and came upon this question. I figured out what my problem was so I am posting this answer for posterity and anyone else who runs across this.
Starting with virtualenv 1.7 --no-site-packages became the default behavior. To make global site packages importable (which used to be the default) you must use the option --system-site-packages when you create the virtualenv.
这是一种解决方法:
https://bugs.launchpad.net/ ubuntu/+source/python-virtualenv/+bug/780220
Here is a workaround:
https://bugs.launchpad.net/ubuntu/+source/python-virtualenv/+bug/780220