当我尝试在命令行中运行vim时,我遇到了Python错误

时间:2012-11-18 16:05:16

标签: python vim terminal

当我尝试在终端中运行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/

5 个答案:

答案 0 :(得分:8)

在我的开发计算机上安装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

答案 1 :(得分:1)

编辑:

找到安装它的软件包:

dpkg -S /usr/include/python2.7/pyconfig.h

然后重新安装包:

apt-get install --reinstall <package name>

如果不起作用,请下载包@:

http://packages.ubuntu.com/oneiric/amd64/python2.7-minimal/download

并手动安装:

$ sudo dpkg -i python2.7-minimal_2.7.2-5ubuntu1_amd64.deb

2ND编辑:

此处的另一位用户遇到了同样的问题:

ViM-LaTeX, python, and Mac OS 10.8.1 and a weird error

似乎解决了购买安装Xcode和命令行工具的问题。

值得一试。

答案 2 :(得分:1)

您可能正在使用默认的Vim(/usr/bin/vim)。您应该使用MacVim的CLI可执行文件:$ /path/to/MacVim.app/Contents/MacOS/vim

MacVim附带mvim脚本。把它放在$PATH的某个地方,然后只需$ mvim -v

答案 3 :(得分:0)

由于Zirak的解决方案,我能够解决问题,如下所示:http://clearfix.be/2012/08/05/fix-mountain-lion-10-8-python-ioerror-pyconfig-h-error/

对不起有人接受这个,但由于你的解决方案都没有为我解决,Zirak是评论,我决定自己回答这个问题。 :)

答案 4 :(得分:0)

尝试运行'kodi'(xbmc)#output:/usr/include/python2.7/pyconfig.h(没有这样的文件或目录)

$ ls which python -l  #-rwxrwxr-x 1 someone1 someone1 2993744 Dec 2 11:40 / home / someone1 / bin / python

$ mv / home / someone1 / bin / python / home / someone1 / bin / python1

$ python #output:/ usr / bin / python

现在可以了!