7

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?

MarkK
  • 968
  • 2
  • 14
  • 30
  • 3
    Mhm, no. What you should do is stop mixing `pip` and `apt` :). You cannot expect a package manager to be aware of other package managers. Instead you should take care that you are not using two different package managers that try to install into the same prefix. – cel Oct 24 '15 at 09:37
  • 2
    Don't mix `pip` and `apt`'s Ubuntu installations. Even if `pip` installs in the same directory Ubuntu will not know about the package and you may overwrite it using `apt`. – Bakuriu Oct 24 '15 at 09:38
  • 3
    I agree with your comment, but this cannot be avoided sometimes packages on apt-get are pre-compiled so I want to use them for the install and some pip packages and not in the apt-get universe so I need the best of both worlds. Maybe what I should be asking then is how can I make pip install to the same location as apt-get, maybe? – MarkK Oct 24 '15 at 09:42
  • 1
    There are other strategies to solve that problem: Many python packages that need compiling are available as binary wheels. You can choose to install these with pip instead of compiling yourself. Another strategy is to create a local `virtualenv` that is aware of the packages of its parent. – cel Oct 24 '15 at 09:46
  • I've used virtualenv are you saying you can create one aware of packages install by ``apt-get``? Also, I would be very interested to hear an answer suggesting/show binary wheels? – MarkK Oct 24 '15 at 09:47

1 Answers1

4

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.

Community
  • 1
  • 1
cel
  • 30,017
  • 18
  • 97
  • 117