Virtualenv 不使用全局包 [英] Virtualenv not using global packages

查看:35
本文介绍了Virtualenv 不使用全局包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助诊断 virtualenv 问题.它要下载安装numpy和lxml,同时在全局站点包中有符合版本要求的已安装版本.

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

版本:Ubuntu 11.04、Python 2.7.1+、virtualenv 1.4.9

Versions: Ubuntu 11.04, Python 2.7.1+, virtualenv 1.4.9

更新:virtualenv 1.5.1 和更新版本按预期工作.还是很好奇是什么问题.

Upd: virtualenv 1.5.1 and newer works as expected. Still curious what was the problem.

推荐答案

根据提出这个问题的时间,我的回答并不能解决 OP 的问题,但我遇到了类似的问题,于是想到了这个问题.我弄清楚我的问题是什么,所以我将这个答案发布给后代和其他遇到这个问题的人.

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.

从 virtualenv 1.7 开始 --no-site-packages 成为默认行为.要使全局站点包可导入(以前是默认设置),您必须在创建 virtualenv 时使用选项 --system-site-packages.

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.

这篇关于Virtualenv 不使用全局包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆