Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop pip installing dependancies already installed using apt-get

How do I make sure packages installed using pip don't install dependancies already installed using apt-get?

For example, on Ubuntu you can install the package Numpy using apt-get install python-numpy. Which gets installed to:

usr/local/lib/python2.7/dist-packages 

I've noticed that when I install a package that requires numpy using pip for example, pip install scipy instead of skipping the numpy dependancy it installs again to a different location.

/usr/lib/python2.7/dist-packages

What pip should do is skip any python packages installed globally, right?

like image 409
MarkK Avatar asked Oct 24 '15 09:10

MarkK


1 Answers

In key here is to prevent multiple package managers to install into the same directories.

One strategy is to create a virtualenv that is aware of the package of its parent interpreter. This can be done by using the --system-site-packages option.

virtualenv -p /usr/bin/python --system-site-packages py27
source py27/bin/activate

This environment will not be empty by default. You may want to compare /usr/bin/python -m pip list and python -m pip list.

See also this question


For many (scientific) packages there are also wheels available on pypi. Wheels are already binary and thus need no further compilation.

like image 154
cel Avatar answered Oct 05 '22 03:10

cel