When I try to run vim in command line I get Python errors

旧街凉风 提交于 2019-12-08 16:24:02

问题


When I try running vim in the Terminal (so as to follow @romainl's suggestion in my other question) I get lots of Python errors, which all boil down to:

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

Why is this? I can use Python or Sublime Text even, without any problems.

The full list of errors is the following:

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)

Extra info:
I am on Mac OS X Mountain Lion (OS 10.8)

EDIT:
I tried @BobDunakey idea with no success, the idea was to use sudo. I still get the same errors.

EDIT 2:
I was able to solve the problem thanks to Zirak's solution, which is the following: http://clearfix.be/2012/08/05/fix-mountain-lion-10-8-python-ioerror-pyconfig-h-error/


回答1:


Just had the exact IOError while installing spf13-vim on my dev machine...

This fixes the problem:

$ 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

Taken from here.




回答2:


You are probably using the default Vim (/usr/bin/vim). You should use MacVim's CLI executable instead: $ /path/to/MacVim.app/Contents/MacOS/vim.

MacVim comes with a mvim script. Put it somewhere in your $PATH and simply do $ mvim -v.




回答3:


EDIT:

find the package that installed it with:

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

Then reinstall the package:

apt-get install --reinstall <package name>

If that doesn't work download the package @:

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

and manually install them with:

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

2ND EDIT:

Another user here had the same issue:

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

seemed to fix it buy installing Xcode and the command line tools.

Worth a shot imo.




回答4:


I was able to solve the problem thanks to Zirak's solution, which is the following: http://clearfix.be/2012/08/05/fix-mountain-lion-10-8-python-ioerror-pyconfig-h-error/

Sorry guys for accepting this one, but since neither of your solutions solved it for me, and Zirak's is a comment, I decided to answer the question myself. :)




回答5:


trying to run 'kodi' (xbmc) #output: /usr/include/python2.7/pyconfig.h (No such file or directory)

$ 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

$ which python #output: /usr/bin/python

now it works !



来源:https://stackoverflow.com/questions/13441820/when-i-try-to-run-vim-in-command-line-i-get-python-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!