[Pythonmac-SIG] sys.path on Leopard

Jack Jansen Jack.Jansen at cwi.nl
Thu Nov 1 21:14:38 CET 2007


On 1-Nov-2007, at 20:45 , Brian Granger wrote:
> Running python setup.py install on Leopard causes packages to be
> installed in the usual:
>
> /Library/Python/2.5/site-packages
>
> But, Apple put this directory _after_
>
> /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/ 
> python
>
> in sys.path.  This, even if a user installs a newer version of one of
> these packages, the builtin  python will always use Apple's older
> version.


Bah. The order is very strange:
- First most of the Python-supplied and Apple-supplied directories,
- Then /Library/Python/2.5/site-packages
- Then PyObjC, which is also Apple-supplied
- Then $HOME/Library/Python/2.5/site-packages, if it exists.

By all means, report a bug.

There is a workaround that packages can use to fix this, by the way,  
through using Python code inside a .pth file. I used that in the  
distant past to allow packman to fix bugs in system packages.

I put the following line (without indentation) into ~/Library/Python/ 
2.5/site-packages/HackPath.pth
	import sys ; sys.path.insert(0, '/Users/jack/MyPythonPrependedPath')
And, indeed, '/Users/jack/MyPythonPrependedPath' ends up as the first  
entry in sys.path.
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma  
Goldman




More information about the Pythonmac-SIG mailing list