3

I have a fairly straightforward Ubuntu (13.04) desktop installation, which comes complete with several Ubuntu-packaged Python utilities -- these live in /usr/lib/python2.7 and are owned by root. I call these "system" Python packages.

I also do a lot of scientific work with Python and so I have installed tools like numpy, matplotlib, etc. using pip -- these live in /usr/local/lib/python2.7 and are owned by me (I chowned /usr/local because I'm the only user on this machine). I call these "local" Python packages. I put the local path in front of the system one in my PYTHONPATH so that I load local packages preferentially.

Now, I'm trying to upgrade one of the local packages that I installed using pip, and pip is failing because it wants to uninstall a dependent system package as part of the upgrade process.

I have two questions about this, addressing the problem from each end :

One way to fix this problem is to get pip to upgrade my local packages and ignore the system-installed ones (if possible). Can I prevent pip from trying to uninstall a system package during a local package upgrade, but only for one dependency ?

Another way would be to have pip install a newer version of the package, and then use that version to satisfy dependencies in apt related tools. Is there a way to tell Ubuntu that a pip-installed package will satisfy an apt dependency ?

(I am familiar with virtualenv, but on this machine I only ever use this one environment, so I'd really like to avoid keeping track of whether I'm working in the correct virtualenv.)

lmjohns3
  • 133
  • 1
  • 2
  • 8
  • Even if I'd only use one environment, I would still wrap it in a virtualenv. Your question is not completely clear to me. – don.joey Aug 16 '13 at 18:25
  • I figured that would be the first answer, so I updated my questions a bit ; hopefully it'll be clearer what I'm asking. – lmjohns3 Aug 16 '13 at 18:30

1 Answers1

4

If you do not want pip to install or uninstall any dependencies you can use

pip install --no-deps package_name

Be ware that you are in that case responsible for making sure the different dependencies needed for the package you install are satisfied.

To use it when upgrading a package use:

pip install -U --no-deps package_name

For a similar problem, cf. Drag forward installed Python packages when upgrading

don.joey
  • 28,662
  • I ended up using this in combination with a virtualenv. It ended up being simpler to have a way to completely separate my pip-installed packages from the system ones. – lmjohns3 Aug 21 '13 at 14:44
  • That is exactly the same setup I have. You can also look into virtualenvwrapper if you start using different venvs. – don.joey Aug 21 '13 at 14:52