Suddenly (perhaps after updating the package or something else) 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 with :python import io
).
I struggled with this for the last two hours, I donโt know what the problem is, reinstalled python and vim several times, both from the source and from aptitude, no difference. I noticed that python inside vim uses a funny way compared to 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 do not use virtualenv
(I noticed that some people come across this when configuring virtualenv
).
You should also point out that Python works great with the command line, and I can happily import io
when I start the interpreter, and that this happens with both vim 8 compiled from the source and vim-nox from aptitude.
Is this a problem with how python sees its path
inside vim? I am in my mind, I do not know what to do to fix it.