Vim 中的错误:"YouCompleteMe unavailable: This package should not be accessible on Python 3"

Error in Vim: "YouCompleteMe unavailable: This package should not be accessible on Python 3"

当我尝试在 vim 中使用 YouCompleteMe 插件时,出现以下错误:

YouCompleteMe unavailable: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted

但是,只有在我的虚拟环境中打开 vim 时才会出现此错误。当 virtualenv 不活动时它工作正常。我的猜测是 YouCompleteMe 是用 python 2 编写的,由于某种原因在虚拟环境中看不到 python2 解释器,但我不确定如何修复它。似乎没有关于该主题的 Stack Overflow 问题,但 ycm-users Google 组中出现了类似的问题,但没有得到答复。

我在 Ubuntu 14.04,使用 vim 7.4 版。

听起来好像你在使用 using python 3 inside virtualenv。就vim而言,你是运行 python 3 ycm

不支持

https://github.com/Valloric/YouCompleteMe/issues/1140

解决方法是从您的 virtualenv

外部打开 vim

看起来这是一个错误:

https://github.com/Valloric/ycmd/pull/578

In PR #448, I made the assumption that the site-packages paths are always placed after the standard library path so that if we insert the python-future module just before the first site-packages path, it would necessary be after the standard library. Turns out that it is not true when a site-packages path is added to the PYTHONPATH environment variable, e.g, when using the software ROS. See issue Valloric/YouCompleteMe#2186. When this happens, the python-future module will raise the following exception on Python 3:

 ImportError: This package should not be accessible on Python 3.
 Either you are trying to run from the python-future src folder or
 your installation of python-future is corrupted.

We prevent this by looking for the standard library path in sys.path and by inserting the python-future module just after it. If we can't find it, we raise an exception since YCM and ycmd cannot work without it.

Fixes Valloric/YouCompleteMe#2186

合并上述拉取请求后,您应该能够通过拉取更新(或如果尚未克隆存储库)并重新安装来解决问题。