temoto
temoto

Reputation: 5577

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
'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.

Upvotes: 1

Views: 2991

Answers (2)

rpkelly
rpkelly

Reputation: 2156

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

Upvotes: 0

joshcartme
joshcartme

Reputation: 2747

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.

Upvotes: 10

Related Questions