All of a sudden (probably after a package update or something) vim stopped working with YouCompleteMe and throws:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: No module named _io
(this also happens when I try to import io from inside vim using :python import io
).
I've been battling this for the last couple of hours, no idea what the problem is, reinstalled python and vim several times, both from source and from aptitude, no difference. I've noticed that python inside vim uses a funny path compared to from the command line:
~$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; print sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
>>>
And from vim:
:python import sys; print sys.path
['/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '
/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-pa
ckages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode', '_vim_path_']
I am not usingvirtualenv
(I've noticed some people running into this with virtualenv
set up).
Also must point out that Python works perfectly fine from the command line and I can happily import io
when launching the interpreter and that this happens with both vim 8 compiled from source and vim-nox from aptitude.
Is it an issue with how python sees its path
inside vim? I'm at my wits' end, no idea what to do to fix this.
YouCompleteMe provides an option g:ycm_server_python_interpreter to set a specific interpreter.
Just add let g:ycm_server_python_interpreter = path/to/your/interpreter
in your .vimrc
with the path of your favored interpreter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With