Skip to content

Instantly share code, notes, and snippets.

@sonicradish
Created July 26, 2012 12:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sonicradish/3181811 to your computer and use it in GitHub Desktop.
Save sonicradish/3181811 to your computer and use it in GitHub Desktop.
Fix Mountain Lion 10.8 Python IOError pyconfig.h Error
After upgrading to Mountain Lion : 10.8 I noticed that I was getting Python errors which prevented me from starting vim:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 565, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 547, in main
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 278, in addusersitepackages
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 253, in getusersitepackages
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 243, in getuserbase
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py", line 523, in get_config_var
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py", line 419, in get_config_vars
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py", line 298, in _init_posix
IOError: invalid Python installation: unable to open /usr/include/python2.7/pyconfig.h (No such file or directory)
First I tried the first step from this: https://gist.github.com/3180261 - which didn't stop the errors from displaying...
I still need to find where the path is being incorrectly set and fix it there, but if you need to be up and running quickly with vim, this should also work:
sudo mkdir -p /usr/include/python2.7
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/Current/include/python2.7/pyconfig.h /usr/include/python2.7/pyconfig.h
@rudeb0t
Copy link

rudeb0t commented Jul 27, 2012

I've just upgraded to Mountain Lion and encountered the same error. Installing the updated command line tools for XCode 4.4 fixes this error. If you are using ropevim or custom Python Vim scripts that use 3rd-party modules, you will need to re-install them since the upgrade wipes everything from /Library/Python/2.7/site-packages directory.

@sonicradish
Copy link
Author

Thanks for the note. I updated XCode right before upgrading to 10.8 but hadn't pulled the command line tools update yet.

@rudeb0t
Copy link

rudeb0t commented Jul 28, 2012

This gist fixes import errors for ropemode if you are using ropevim. For some reason the embedded Python interpreter in system Vim uses a different sys.prefix from the command line version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment