davidhalter / jedi-vim

Using the jedi autocompletion library for VIM.
MIT License
5.27k stars 370 forks source link

jedi-vim error: jedi#setup_python_imports: Traceback (most recent call last) #1050

Closed puraminy closed 3 years ago

puraminy commented 3 years ago

I installed vim from source on linux Ubuntu 16 by enabling python. You also pointed to check python3 import sys; print(sys.version) but you didn't say what it should return?! It returns: [GCC 5.4.0 20160609]

It's the output of :

vim --version | grep python

+cryptv          +linebreak       +python/dyn      +vreplace
+cscope          +lispindent      +python3/dyn     +wildignore

But I get the following error when I try to open a python file:

jedi-vim error: jedi#setup_python_imports: Traceback (most recent call last):
  File "<string>", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 896, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1139, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1115, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1093, in _legacy_get_spec
  File "/usr/lib/python3.5/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/usr/lib/python3.5/imp.py", line 172, in load_source
    module = _load(spec)
  File "/home/pouramini/.vim/bundle/jedi-vim/pythonx/jedi_vim.py", line 116, in <module>
    import jedi
  File "/home/pouramini/.vim/bundle/jedi-vim/pythonx/jedi/jedi/__init__.py", line 32, in <mo
dule>
    from jedi.api import Script, Interpreter, set_debug_function, preload_module
  File "/home/pouramini/.vim/bundle/jedi-vim/pythonx/jedi/jedi/api/__init__.py", line 13, in
 <module>
    import parso
  File "/home/pouramini/.vim/bundle/jedi-vim/pythonx/parso/parso/__init__.py", line 41, in <
module>
    from parso.parser import ParserSyntaxError
  File "/home/pouramini/.vim/bundle/jedi-vim/pythonx/parso/parso/parser.py", line 113
    node_map: Dict[str, type] = {}
davidhalter commented 3 years ago

You should show us what :python3 import sys; print(sys.version) prints.

I'm pretty sure there's something wrong with your Vim's Python3 support.

puraminy commented 3 years ago

You should show us what :python3 import sys; print(sys.version) prints.

I'm pretty sure there's something wrong with your Vim's Python3 support.

It seems that I just showed part of what it returns. It prints:

3.5.2 (default, Jan 26 2021, 13:30:48) 
[GCC 5.4.0 20160609]

If it's the version of python, I should say that I use python 3.7.10, which is what python3 --version or python --version returns. I should say I use conda virtual env.

It seems outside of conda python3 --version returns 3.5.2

puraminy commented 3 years ago

I managed to install python 3.7 system-wide and build vim using it. I installed:

sudo apt install python3.7
sudo apt install python3.7-dev

and finally built vim using:


cd ~
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            --enable-python3interp=yes \
            --with-python3-config-dir=$(python3.7-config --configdir) \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk2 \
            --enable-cscope \
            --prefix=/usr/local
make
sudo make install

Now it prints 3.7.10 in vim! and jedi is loaded! I suggest you to point to what :python3 import sys; print(sys.version) should return and match it with python3 --version in README

davidhalter commented 3 years ago

Python 3.5 is not supported anymore by jedi-vim (since it is officially end-of-life). Happy you got it running with Python 3.7 :)