Partially invalid sys.path - how can I fix it (not append to it)?

dieter dieter at handshake.de
Tue Sep 29 07:55:38 CEST 2015


Pierre Rouleau <prouleau001 at gmail.com> writes:
> On a OS/X 101.10.5 (Yosemite) system, the system Python just got updated to 2.7.10 but it sys.path is partially invalid. How can I fix that?
> ... details removed ...

You have found out that the execution of "site.py" inserts
the invalid entries to "sys.path". I remember that there is
a document (it was somewhere on "python.org", when I last read it, but
this was years ago) which describes what "site.py" does.
In particular, it interprets "*.pth" files it finds via "sys.path"
and extends "sys.path" according to the content of those files.
I find it quite likely, that one of those "*.pth" files might
cause the wrong entry in your "sys.path".


> Also note that the sys.prefix is "/usr"
> I think it should be "/usr/lib/python2.7" or "/System/Library/Frameworks/Python.framework/Versions/2.7"

I think this is correct: Python expects the directory corresponding
to "prefix" to have subdirectories "bin", "lib/python<version>" and "include".



More information about the Python-list mailing list