Search code examples
pythonpython-3.xvimvirtualenvyoucompleteme

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


When I attempt to use the YouCompleteMe plugin in vim, I get the following error:

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

However, I only get this error when I open vim within my virtual environment. It works fine when a virtualenv is not active. My guess is that YouCompleteMe is written in python 2, and for some reason can't see the python2 interpreter from inside the virtual environment, but I am not sure how to fix it. There does not appear to be a Stack Overflow question on the subject, but a similar issue came up in the ycm-users Google Group and went unanswered.

I'm on Ubuntu 14.04, using vim version 7.4.


Solution

  • Looks like it's a bug:

    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

    With the above pull request merged, you should be able to fix the issue by pulling the updates--or cloning the repo if haven't already--and reinstalling.