Vim中出错:“YouCompleteMe不可用:在Python 3上无法访问此包”

时间:2016-08-18 00:46:22

标签: python python-3.x vim virtualenv youcompleteme

当我尝试在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 Group中出现了类似的问题并且未得到答复。

我在Ubuntu 14.04上使用vim版本7.4。

2 个答案:

答案 0 :(得分:1)

看起来像是一个错误:

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

  

在PR#448中,我假设站点包路径总是放在标准库路径之后,这样如果我们在第一个站点包路径之前插入python-future模块,那么必须在之后标准库。事实证明,当将站点包路径添加到PYTHONPATH环境变量时,例如,当使用软件ROS时,情况并非如此。请参阅问题Valloric / YouCompleteMe#2186。发生这种情况时,python-future模块将在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.
     

我们通过在sys.path中查找标准库路径并在其后面插入python-future模块来防止这种情况。如果我们找不到它,我们就会引发异常,因为没有它,YCM和ycmd就无法工作。

     

修正Valloric/YouCompleteMe#2186

上述拉取请求合并后,您应该能够通过提取更新来解决问题 - 或者如果已经没有克隆回购 - 并重新安装。

答案 1 :(得分:0)

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

不支持的python 3

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

解决方法是从virtualenv外部打开vim