It’s hardcoded in the Python executable, I’m afraid:-(

Just tried “python -s -S -v”, and the Extras/lib/python is still in sys.path.

That wasn’t a very smart move by the Apple engineers, I guess….

What you could do (but this is getting rather hacky) is create a 
/Library/Python/2.7/site-packages/removeSystemExtras.pth where you import sys 
and manually remove the Extras entries. Be careful, putting code (as opposed to 
pathnames) into a .pth file requires the line to start with “import “.

Jack

> On  13-Sep-2016, at 23:37 , Andrew Jaffe <a.h.ja...@gmail.com> wrote:
> 
> Hi,
> 
> 
>> On 13 Sep 2016, at 22:26, Jack Jansen <jack.jan...@cwi.nl> wrote:
>> 
>> You’re absolutely right (both on SIP and on 
>> /Library/Frameworks/Python.framework probably being a python.org install), 
>> sorry for the confusion.
>> 
>> This seems to be due to the way Apple has done the “Extras” directory, and 
>> adding things there to sys.path.
>> 
>> See for example https://github.com/pypa/pip/issues/2468
>> 
>> If you can get rid of 
>> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python 
>> in sys.path you should be all set.
> 
> Thanks, guys.
> 
> Indeed, these /System/Library dirs are in sys.path:
> 
>    In [1]: import sys
>    In [2]: print [p for p in sys.path if 'System' in p]
>    
> ['/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC’]
> 
> But I’m still confused: why is this problem only showing up now? Is the same 
> setup that everyone has? Or is it just me for some reason? How and where 
> would sys.path be set to this, and how and where should I change it? (Without 
> disabling SIP, please!)
> 
> Andrew
> 
> 
> 
> 
> 
> 
> 
>>> On  13-Sep-2016, at 22:59 , Glyph Lefkowitz <gl...@twistedmatrix.com> wrote:
>>> 
>>> 
>>>> On Sep 13, 2016, at 12:05 PM, Jack Jansen <jack.jan...@cwi.nl> wrote:
>>>> 
>>>> I think 
>>>> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
>>>>  is a very old location for storing Python packages. Recently things have 
>>>> been installed in /Library/Python/2.7/site-packages.
>>>> 
>>>> Could it be that you’ve installed pyobjc a couple of OSX releases ago?
>>> 
>>> This is always worth checking ;).  Particularly if it was a few Setuptools 
>>> releases ago.  Also worth checking: ~/Library/Python.
>>> 
>>>> And could it be that the OSX upgrade that introduced SIP somehow didn’t 
>>>> clean out user-installed things from /Library/Frameworks before turning 
>>>> off write permission?
>>> 
>>> SIP locks down /System, not /Library.
>>> 
>>>> A possible workaround is to turn off SIP (or boot from the recovery 
>>>> partition), record what is in 
>>>> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
>>>>  and then clean it out. Then after a reboot re-install the packages you’re 
>>>> still using.
>>> 
>>> This should be an _absolute_ last resort, though.  You should be able to 
>>> clean out /Library just fine.  If you have a 
>>> /Library/Frameworks/Python.framework, that's probably Python.org python, 
>>> not system python.
>>> 
>>> -glyph
>> 
>> --
>> Jack Jansen, <jack.jan...@cwi.nl>, http://www.cwi.nl/~jack
>> If I can't dance I don't want to be part of your revolution -- Emma Goldman
>> 
>> 
>> 
> 

--
Jack Jansen, <jack.jan...@cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma Goldman



_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
https://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG

Reply via email to