Why does /usr/lib/... have precedence over /usr/local/lib/... in python's sys.path?

Asked by Darren Dale

I am using ubuntu Jaunty, and want to use a PyQt4 snapshot. I can't remove the version provided by Jaunty because other packages depend on it. The old version lives in /usr/lib/python2.6/dist-packages (why was that renamed from site-packages?) and when I installed the snapshot it went to /usr/local/lib/python2.6/dist-packages. That's fine, but /usr/local/lib/... is listed after /usr/lib in python's sys.path, so when I try to import PyQt4 I get the Jaunty version, not the snapshot.

I know I can set PYTHONPATH to override the default setting, but I would consider this to be a bug. If I manually install a package, I obviously prefer it to the one provided by Jaunty's package manager. Jaunty respects that decision in other contexts: the default PATH lists /usr/local/bin before /usr/bin. If this is the intended behavior for python's sys.path, would someone please explain the reasoning?

Thanks,
Darren

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Darren Dale (dsdale24) said :
#1

This actually seems to be a pretty significant divergence from default python behavior, having manually installed packages go to /usr/local instead of /usr. Could someone point me to a discussion of why it was implemented? Will it be implemented upstream in a future version of python?

I don't think the PYTHONPATH solution I mentioned to modify the search order is a good one. Jaunty allows us to install python-3.0 along with version 2.6, but PYTHONPATH is used by versions of python (see http://bugs.python.org/issue2375), so it would be a really bad idea to include /usr/local/lib/python2.6/dist-packages on PYTHONPATH.

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Darren Dale (dsdale24) said :
#3

I am still questioning the wisdom of modifying the standard python behavior in this way. Plenty of people want to install their own local copy of python in usr/local. Upstream python does not support splitting package installs into /usr and /usr/local. Plus, ubuntu changes the installation target from site-packages to dist-packages. The whole situation seems arbitrary and I cant find an explanation for why anyone bothered to put these changes in ubuntu. It must have been discussed somewhere.

Revision history for this message
Launchpad Janitor (janitor) said :
#4

This question was expired because it remained in the 'Open' state without activity for the last 15 days.