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

标签 python python-3.x vim virtualenv youcompleteme

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

YouCompleteMe 不可用:在 Python 3 上不应访问此包。您正尝试从 python-future src 文件夹运行,或者您安装的 python-future 已损坏

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

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

最佳答案

看起来这是一个错误:

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

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

关于python - Vim : "YouCompleteMe unavailable: This package should not be accessible on Python 3" 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39008318/

相关文章:

python - 字典的值列表

python - 列包含列 1

python - 使用分隔符连接数据框的列

vim - 从腻子中运行的vim复制内容

python - 为什么 Python 的 dict.keys() 返回一个列表而不是一个集合?

python - 使用 Python 3 从 PDF 解析中提取标题和子标题

python - 响应 503 python 请求

vim 获取 vim foldmarker 的当前值

vim - 如何在vim中编辑现有的键映射?

python - 如何通过XML数据更快的更新MySQL?