0
-- 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?

5 Answers5

1

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)

0

I installed jedi-vim with pathogen, and it now works.

pip install --user jedi
cd ~/.vim/bundle/
git clone https://github.com/davidhalter/jedi-vim.git

You can also run this:

sudo apt-get install vim-python-jedi

This should help

LychmanIT
  • 695
  • 6
  • 13
0

uninstall was not a solution in my case, vim complained at the very beginning, that is not finding python support I did the following:

cd /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/

mv _io.so _io.so.orig
cp /usr/lib/python2.7/lib-dynload/_io.so ./

( I've built vim8 from source - from github.com/vim/vim.git )

./configure --enable-pythoninterp --with-python-config-dir=/usr/lib/python2.7/config/

make

sudo make install)
goto
  • 7,908
  • 10
  • 48
  • 58
0

At least for Ubuntu 16.04, this is caused because the default Vim packages are compiled against Python 3.5. To get this error fixed, besides the related packages to Jedi, you need to install anything you have regarding Vim and installing the following packages:

sudo apt-get install vim-addon-manager vim-common vim-gnome-py2 \
vim-gtk3-py2 vim-gui-common vim-nox-py2 vim-python-jedi vim-runtime
0

If you use https://github.com/amix/vimrc , you can upgrade it to solve this problem.

cd ~/.vim_runtime
git reset --hard
git clean -d --force
git pull --rebase
python update_plugins.py
reg
  • 9