开发者

Virtualenv not using global packages

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
开发者_C百科'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.


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.


This bug is due to the shipped version of virtualenv (1.4.9 in ubuntu 11.04). This version does not copy the directory config/ of the python installation in the virtualenv, so sysconfig, introduced in python2.7 is broken.

Here is a workaround:

mkdir -p <VIRTUALENV_PATH>/local/lib/python2.7/config/
cp /usr/lib/python2.7/config/Makefile <VIRTUALENV_PATH>/local/lib/python2.7/config/Makefile

https://bugs.launchpad.net/ubuntu/+source/python-virtualenv/+bug/780220

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜