2

Following (add2virtualenv (virtualenv wrapper) does not work with scipy) I symlinked my site-packages numpy directory into my virtualenv site-packages. In my virtualenv, I can do import numpy with no problems.

However, when I try to do pip install pandas in the virtualenv, pip tries to re-install numpy. How can I make pip recognize that numpy is already installed?

Community
  • 1
  • 1
Thomas Johnson
  • 10,776
  • 18
  • 60
  • 98
  • would it be easier just copy over numpy to the site-packages in your venv? Or just create a venv with access to your system packages `--system-site-packages` – Padraic Cunningham Feb 03 '15 at 00:48
  • Would copying vs symlinking change anything? I don't want to pull everything in with `--system-site-packages`, just numpy and scipy which are a pain to install in Ubuntu (because you have to set up all the BLAS/LaPack stuff properly) – Thomas Johnson Feb 03 '15 at 00:56
  • well copying numpy from your system to you venv with a simple `cp -r `should certainly work, I would have thought a symlink would have also but I have never done it. – Padraic Cunningham Feb 03 '15 at 01:11
  • Going into my virtualenv site-packages directory and doing `cp -r /usr/lib/python2.7/dist-packages/numpy ./` did not change anything. `pip list` still does not show numpy and installing pandas still tries to re-install numpy. – Thomas Johnson Feb 03 '15 at 01:17
  • did you copy the `egg-info`? – Padraic Cunningham Feb 03 '15 at 01:32
  • Once the egg and numpy dir is copied over your should have no issue and pip list should show numpy, the egg is important. just copying that alone will make pip think it is installed but obviously without copying the package dir you won't be able to use it – Padraic Cunningham Feb 03 '15 at 01:48
  • Ah, copying the `egg-info` fixed it! If you want to add that as an answer I will mark it accepted – Thomas Johnson Feb 03 '15 at 01:50

1 Answers1

3

As discussed in the comments, you can copy the .egg and the module directory into your virtualenv site-packages directory:

sudo cp -r  path_to_system/numpy your_venv/lib/python3.4/site-packages/
sudo cp -r  path_to_system/numpy-x.x.x-pyx.x.egg-info  your_venv/lib/python3.4/site-packages/
Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321