Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip can't upgrade a built-in package in ubuntu 15.04

I no longer seem to be able to upgrade a package already installed in Ubuntu 15.04. Pip still works, installing the package into /usr/local/python2.7/dist-packages, but the path lists /usr/python2.7/dist-packages at the top, and even PYTHONPATH can't get something above that line. I believe this works in older Ubuntus. I've been trying to find something in /usr/python/site.py, but it seems to do the right thing. Adding -S does seem to stop the non-local version from being at the top. I've seen this on two computers, I believe.

Some examples of the need for this: Updating to get a required feature/bugfix (for PILLOW, in my case) without APT uninstalling a bunch of packages that list that package as a requirement.

Edit: For clarification, the question is: I want to reorder the directory search order to recover Ubuntu 14.10 behavior. There are better ways to do this on many systems, but I want to use the built in apt packaging, just with one or two (potential) newer packages, like IPython and the like, rather than use virtual-env and Anacoda (both of which I use on other systems). It looks like my desired behavior is the documented Debian behavior, so I'm not sure why it's reordering the path.

Here's the path to demonstrate the problem, notice the PYTHONPATH variable is in the middle, with two git folders:

>>> sys.path
['',
'/usr/lib/python2.7/dist-packages', 
'/usr/local/lib/python2.7/dist-packages/requests-2.6.0-py2.7.egg', 
'/usr/local/lib/python2.7/dist-packages/octave_kernel-0.10.0-py2.7.egg',
'/home/username/git/maya',
'/home/username/git/udaq/pyUDAQ',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk', 
'/usr/lib/python2.7/lib-old', 
'/usr/lib/python2.7/lib-dynload', 
'/usr/local/lib/python2.7/dist-packages', 
'/usr/lib/python2.7/dist-packages/PILcompat', 
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7', 
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/wx-3.0-gtk2']

For reference, I have a matching system running 14.04, and it has exactly the expected behavior. The two PYTHONPATH dirs come first, then then later on the local dist-packages are above the built in.

like image 790
Henry Schreiner Avatar asked Sep 27 '22 21:09

Henry Schreiner


2 Answers

There is a -t switch in pip. It allows you to configure a directory where pip installs packages.

You can set the directory in a config file and forget about specifying it each time you install or upgrade packages

But generally it is a bad idea to upgrade packages installed by apt

like image 116
Alik Avatar answered Sep 30 '22 10:09

Alik


Use virtualenv:

install virtualenv

$ sudo apt-get install python-virtualenv

create environment in MYENV directory

$ virtualenv MYENV

activate environment in current shell (your app will need this as well on it's startup script)

$ . MYENV/bin/activate

use pip/python from your venv located in MYENV directory (you own)

(MYENV)$ pip ...  
like image 22
Michał Šrajer Avatar answered Sep 30 '22 10:09

Michał Šrajer