当我尝试在终端中运行vim(以便遵循@romainl's suggestion in my other question)时,我遇到了许多Python错误,这些错误都归结为:

IOError: invalid Python installation: unable to open /usr/include/python2.7/pyconfig.h (No such file or directory)

为什么是这样?我什至可以使用Python或Sublime Text,而不会出现任何问题。

错误的完整列表如下:
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)

额外信息:
我在Mac OS X Mountain Lion(OS 10.8)上

编辑:
我尝试了@BobDunakey的想法,但没有成功,这个想法是使用sudo。我仍然遇到相同的错误。

编辑2:
通过Zirak的解决方案,我得以解决以下问题:http://clearfix.be/2012/08/05/fix-mountain-lion-10-8-python-ioerror-pyconfig-h-error/

最佳答案

在我的开发机器上安装spf13-vim时遇到了确切的IOError ...

这样可以解决问题:

$ 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

采取from here

关于python - 当我尝试在命令行中运行vim时,出现Python错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13441820/

10-13 07:23
查看更多