Search code examples
pythonvimvim-pluginjedi-vim

Autocompletion with Jedi-vim gives Error


-- Omni completion (^O^N^P) Pattern not found

This is the error that I am getting when I look into the :messages in Vim.

Please install Jedi if you want to use jedi-vim.
The error was: dlopen(/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder^@  Referenced fro
m: /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so^@  Expected in: flat namespace^@ in /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework
/Versions/2.7/lib/python2.7/lib-dynload/_io.so

Press ENTER or type command to continue

But I already have Jedi installed using pip

$ pip freeze
jedi==0.9.0
vboxapi==1.0 

I'm trying to run :python import jedi; from vim and it gives the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/jedi/__init__.py", line 41, in <module>
    from jedi.api import Script, Interpreter, NotFoundError, set_debug_function
  File "/usr/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 16, in <module>
    from jedi.parser import Parser, load_grammar
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/__init__.py", line 22, in <module>
    from jedi.parser import tokenize
  File "/usr/local/lib/python2.7/site-packages/jedi/parser/tokenize.py", line 16, in <module>
    from io import StringIO
  File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace
 in /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

Python from my command-line shows the following version

>>> import sys
>>> sys.version
'2.7.12 (default, Jun 29 2016, 14:05:02) \n[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]'
>>>

But from Vim if the run the following command

:python import sys; print sys.version

It outputs

2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]

Now how do I update the python that vim is using? / What exactly is happening here and what do I do to solve it?


Solution

  • This has happened because of the 2 versions python installed on the Mac. One that came by default resided in /usr/bin directory and was 2.7.10 version. One that I installed using brew was in the /usr/local/bin directory and was 2.7.12 version.

    Vim was using the 2.7.10 version but looking for packages in the folders where brew installed packages. So I did a brew uninstall python and everything is working fine.

    (But I lost pip and all the packages installed through pip. I should've been more careful)