Utilizing Mac OSX 10.8.5 and Python 2.7.8. Python was installed using MacPorts and I've verified that the MacPorts install is currently the one I'm working off of. I have problems importing certain packages to my MacPorts install, especially when one of the installed packages conflicts with an older versions utilized by the System Python. As an example, I've verified that a System installed package in my sys.path causing problems importing a current version of Numpy.
python
>>> import numpy
>>> numpy.__version__
'1.6.1' #Bad Version
python
>>> import sys
>>> sys.path.remove('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python')
>>> import numpy
>>> numpy.__version__
'1.9.0' #Good Version
The problem is that '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python' is never explicitly added to $PYTHONPATH or $PATH by conventional means so I do not know how it is being added to sys.path. I would like to permanently block importing things from this path.
What I've already tried:
I read about site.py on the answers here What sets up sys.path with Python, and when? However when I attempt the solutions in the question, they do not work. I tried manually editing site.py and adding the statement sys.path = filter (lambda a: not a.startswith('/System'), sys.path)
to main() function. However the erroneous path still appears even after putting the statement in site.py
The erroneous path comes from a directory utilized by my computer's OS, so deleting the numpy path under /System/Library is not an option. Is there any way I can fix my problem, keeping files under '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python' from automatically being added to sys.path?