Search code examples
pythonmacossystemdyld

messed up my system python


I messed up my osx 10.10 system python. The Versions folder now has a non-standard structure, causing issues. Is there any way I can fix this without a factory reset?

$ /System/Library/Frameworks/Python.framework/Versions/bin/python
dyld: Library not loaded: /Library/Frameworks/Python.framework/Versions/2.7/Python
  Referenced from: /System/Library/Frameworks/Python.framework/Versions/bin/python
  Reason: image not found
Trace/BPT trap: 5

Solution

  • That is not the system Python (the one built into OSX), that resides in /System/Library.

    The one in /Library is something that you have installed afterwards, using the official Python distribution or maybe MacPorts or Homebrew.

    To verify that you are running the OS provided python, run

    which python
    

    It should be

    /usr/bin/python
    

    If it is not, check your $PATH variable.

    Also check your PYTHONPATH

    python -c "import sys;print sys.path"
    

    Make sure that it does contain /System/Library/Frameworks/Python.framework/... and no /Library/Frameworks/Python.framework/... entries.

    Note that the default site-packages resides in /Library/Python/....

    Once you have verified this, you can probably uninstall (or reinstall) the broken Python dist (do a pip freeze > requirements.txt first to reinstall any third party stuff).