Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jedi-vim failed to initialize Python: ":py/py3 import jedi" gives "ImportError: cannot import name 'settings'" #526

Closed
MadWombat opened this issue Jan 13, 2016 · 53 comments

Comments

@MadWombat
Copy link

I get the following error every time I start VIM

Error: jedi-vim failed to initialize Python: jedi#setup_py_version: Vim(py3file):Traceback (most recent call last): (in function jedi#init_python[3]..<SNR>72_init_python[50]..jedi
#setup_py_version, line 18)

I am running on Mac OS X El Captain 10.11.2. Vim is version 7.4.1063, python is version 3.4.3. Jedi is 0.9.0. Both python and vim are installed using brew, vim is installed using --with-python3 flag. :py3 command works, but trying to do :py3 import jedi results in the following

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/wombat/.vim/bundle/jedi-vim/jedi/jedi/__init__.py", line 41, in <module>
    from jedi.api import Script, Interpreter, NotFoundError, set_debug_function
  File "/Users/wombat/.vim/bundle/jedi-vim/jedi/jedi/api/__init__.py", line 16, in <module>
    from jedi.parser import Parser, load_grammar
  File "/Users/wombat/.vim/bundle/jedi-vim/jedi/jedi/parser/__init__.py", line 21, in <module>
    from jedi.parser import tree as pt
  File "/Users/wombat/.vim/bundle/jedi-vim/jedi/jedi/parser/tree.py", line 39, in <module>
    from jedi import cache
  File "/Users/wombat/.vim/bundle/jedi-vim/jedi/jedi/cache.py", line 30, in <module>
    from jedi import settings
ImportError: cannot import name 'settings'

I tried reinstalling everything and re-installing vim with env vi_cv_path_python=/usr/local/bin/python3 brew install --force vim --with-python3 command as was suggested in a similar issue.

Here is :version output for more info.

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 13 2016 15:58:04)
MacOS X (unix) version
Included patches: 1-1063
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +cmdline_info    +emacs_tags      -hangul_input    +menu            +mouse_xterm     +python3         +syntax          +virtualedit     -xsmp
+arabic          +comments        +eval            +iconv           +mksession       +multi_byte      +quickfix        +tag_binary      +visual          -xterm_clipboard
+autocmd         +conceal         +ex_extra        +insert_expand   +modify_fname    +multi_lang      +reltime         +tag_old_static  +visualextra     -xterm_save
-balloon_eval    +cryptv          +extra_search    +jumplist        +mouse           -mzscheme        +rightleft       -tag_any_white   +viminfo         -xpm
-browse          +cscope          +farsi           +keymap          -mouseshape      +netbeans_intg   +ruby            -tcl             +vreplace
++builtin_terms  +cursorbind      +file_in_path    +langmap         +mouse_dec       +path_extra      +scrollbind      +terminfo        +wildignore
+byte_offset     +cursorshape     +find_in_path    +libcall         -mouse_gpm       +perl            +signs           +termresponse    +wildmenu
+cindent         +dialog_con      +float           +linebreak       -mouse_jsbterm   +persistent_undo +smartindent     +textobjects     +windows
-clientserver    +diff            +folding         +lispindent      +mouse_netterm   +postscript      -sniff           +title           +writebackup
+clipboard       +digraphs        -footer          +listcmds        +mouse_sgr       +printer         +startuptime     -toolbar         -X11
+cmdline_compl   -dnd             +fork()          +localmap        -mouse_sysmouse  +profile         +statusline      +user_commands   -xfontset
+cmdline_hist    -ebcdic          -gettext         -lua             +mouse_urxvt     -python          -sun_workshop    +vertsplit       -xim
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -F/usr/local/Frameworks -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FOR
TIFY_SOURCE=1
Linking: /usr/bin/clang   -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -F/usr/local/Frameworks -
Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl  -L/u
sr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/config-3.4m -lpython3.4m -framework CoreFoundation  -lruby.2.2.0 -lobjc -L/usr/local/Cellar/
ruby/2.2.3/lib
@davidhalter
Copy link
Owner

This is very strange. Could you reinstall Jedi? It looks like there's something missing.

@MadWombat
Copy link
Author

I have uninstalled and re-installed jedi. I checked and there is a settings.py file in the jedi install directory. Ran py3 import sys; print(sys.path) here is the output I got, it seems right

['/Users/wombat/.vim/bundle/jedi-vim', '/Users/wombat/.vim/bundle/jedi-vim/jedi', '/Users/wombat/.vim/bundle/python-mode/pymode/libs3', '/Users/wombat/.vim/bundle/python-mode/pymo
de/libs', '/Users/wombat/.vim/bundle/python-mode', '/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python34.zip', '/usr/local/Cellar/python3/3.4.3_
2/Frameworks/Python.framework/Versions/3.4/lib/python3.4', '/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin', '/usr/local/Cell
ar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload', '/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/s
ite-packages', '_vim_path_', '/Users/wombat/.vim/bundle/python-mode/pymode/libs/astroid/brain']

@MadWombat
Copy link
Author

Also, I can import jedi from regular python3 just fine, so something is wrong with either vim, jedi or the plugin.

@davidhalter
Copy link
Owner

I have no idea... It doesn't make any sense. It's definitely not a jedi-vim issue, because you cannot import it directly either.

Did you also check if the .vim/bundle/jedi-vim is correct? And maybe try to install instead with pip?

@strokirk
Copy link

I'm getting a similar error.

Error: jedi-vim failed to initialize Python: jedi#setup_py_version: Vim(return):AttributeError("'RedirectStream' object has no attribute 'closed'",) (in function jedi#init_python..<SNR>88_init_python..jedi#force_py_version..jedi#setup_py_version, line 18)

From what I can see, the issue seems to happen when colorama is imported and colorama.init is run.

jedi-vim/jedi/jedi/debug.py:17

Uninstalling colorama fixes the issue for me.

@tony
Copy link

tony commented Jan 19, 2016

Is this on vim or neovim? My bug in #523 is happening and may be neovim-specific.

@blueyed
Copy link
Collaborator

blueyed commented Jan 19, 2016

The initial report is with Vim.

@MadWombat
Please post the output from :py import jedi (inside of Vim).

@blueyed
Copy link
Collaborator

blueyed commented Jan 19, 2016

Oh, you've posted this already..

Seems to be the same issue as #530 then.

@blueyed
Copy link
Collaborator

blueyed commented Jan 19, 2016

What is the output of :py import sys; print(sys.path) when this happens?

@MikeDacre
Copy link

I am away from my computer and can't add debug info right now, but the one difference between this and #530 is that in #530 I am using python 2 and vim with python 2. I am also on a Mac though, (10.9.5), and both python and vim are installed with homebrew.

@MadWombat
Copy link
Author

I cannot do :py import jedi since I don't have python 2 support compiled in. I have posted the py3 equivalent earlier.

@blueyed
Copy link
Collaborator

blueyed commented Jan 20, 2016

@MadWombat
Yes, I've noticed it later.
What does :py3 import sys; print(sys.path) print?

@MadWombat
Copy link
Author

See this comment
#526 (comment)

@davidhalter
Copy link
Owner

Probably '/Users/wombat/.vim/bundle/jedi-vim' shouldn't be in there?!

@MadWombat
Copy link
Author

Isn't that where the actual jedi-vim module imports things from? Besides, I didn't put it there.

@blueyed
Copy link
Collaborator

blueyed commented Jan 20, 2016

Yes, that's related to the issue then probably:

['/Users/wombat/.vim/bundle/jedi-vim', '/Users/wombat/.vim/bundle/jedi-vim/jedi', ...

I only have '/home/user/.dotfiles/vim/neobundles/jedi' related to Jedi.

The other one should be popped/removed in

sys.path.pop(1)
.
But also when commenting this line I cannot reproduce the issue.

@blueyed
Copy link
Collaborator

blueyed commented Jan 20, 2016

Is everybody with the issue using Mac OS El Captain?

@MadWombat
Copy link
Author

I do. Not sure about everyone else.

@blueyed blueyed changed the title loading issue with python3 Loading issue with python3: "jedi-vim failed to initialize Python" Jan 20, 2016
@blueyed
Copy link
Collaborator

blueyed commented Jan 20, 2016

#447 mentions that it's fixed by removing/disabling python-mode - might be worth a try.

@MadWombat
Copy link
Author

Ehm... but that kinda defeats the purpose. Python-mode has a lot of features I am using. If that is the solution, I would rather disable jedi-vim :)

@blueyed
Copy link
Collaborator

blueyed commented Jan 20, 2016

Please try to reproduce it in the Python interpreter by replicating the sys.path (the two Jedi paths in front).

@MadWombat
Copy link
Author

That worked just fine. I did

import sys
sys.path = [ cut/pasted the paths ]
import jedi

and that didn't cause any errors

@kiminoa
Copy link

kiminoa commented Jan 20, 2016

@blueyed: Yep on el Capitan (10.11.3); python 2.7 in my case.

Exact sad is:

Error: jedi-vim failed to initialize Python: jedi#setup_py_version: Vim(pyfile):Traceback (most recent call last): (in function jedi#init_python..<SNR>8_init_python..jedi#setup_py_version, line 18)

When I run py.test, I get the above + not found in 'runtimepath': "ftdetect/*.vim".

Everything was copacetic until I did the el Capitan upgrade (also upgraded from vim 7.3 to 7.3, sorry for the extra variable.) sigh.

Things that haven't worked:

  1. complete removal of python-mode plugin
  2. uninstall and reinstall vim with brew

:py import sys; print sys(path)

['/Library/Python/2.7/site-packages/MySQL_python-1.2.5-py2.7-macosx-10.10-intel.egg', '/Library/Python/2.7/site-packages/python_aspects-1.1-py2.5.egg', '/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-
packages/nose-1.3.7-py2.7.egg', '/Users/kraymoure/.vim/bundle/jedi-vim', '/usr/local/lib/python2.7/site-packages', '/Users/kraymoure/repos/r1605', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python
27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/V
ersions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python'
, '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versi
ons/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '_vim_path_']

:ver

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 20 2016 13:14:47)
MacOS X (unix) version
Included patches: 1-488
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +cmdline_compl   +diff            +find_in_path    +keymap          +modify_fname    +mouse_xterm     +profile         -sniff           +termresponse    +vreplace        -xterm_save
+arabic          +cmdline_hist    +digraphs        +float           +langmap         +mouse           +multi_byte      +python          +startuptime     +textobjects     +wildignore      -xpm
+autocmd         +cmdline_info    -dnd             +folding         +libcall         -mouseshape      +multi_lang      -python3         +statusline      +title           +wildmenu
-balloon_eval    +comments        -ebcdic          -footer          +linebreak       +mouse_dec       -mzscheme        +quickfix        -sun_workshop    -toolbar         +windows
-browse          +conceal         +emacs_tags      +fork()          +lispindent      -mouse_gpm       +netbeans_intg   +reltime         +syntax          +user_commands   +writebackup
++builtin_terms  +cryptv          +eval            -gettext         +listcmds        -mouse_jsbterm   +path_extra      +rightleft       +tag_binary      +vertsplit       -X11
+byte_offset     +cscope          +ex_extra        -hangul_input    +localmap        +mouse_netterm   +perl            +ruby            +tag_old_static  +virtualedit     -xfontset
+cindent         +cursorbind      +extra_search    +iconv           -lua             +mouse_sgr       +persistent_undo +scrollbind      -tag_any_white   +visual          -xim
-clientserver    +cursorshape     +farsi           +insert_expand   +menu            -mouse_sysmouse  +postscript      +signs           -tcl             +visualextra     -xsmp
+clipboard       +dialog_con      +file_in_path    +jumplist        +mksession       +mouse_urxvt     +printer         +smartindent     +terminfo        +viminfo         -xterm_clipboard
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang   -L. -L/usr/local/lib -L/usr/local/lib -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-m
ulti-2level/CORE -lperl -framework Python   -lruby.2.0.0 -lobjc

@MikeDacre
Copy link

Yup, you can check #530, which was merged into this issue. The error is:

Error: jedi-vim failed to initialize Python: jedi#setup_py_version: Vim(pyfile):Traceback (most recent call last): (in function jedi#init_python[3]..<SNR>111_init_python[48]..jedi#setup_py_version, line 18)

@blueyed blueyed changed the title Loading issue on Mac OS El Capitan: "jedi-vim failed to initialize Python" jedi-vim failed to initialize Python: ":py/py3 import jedi" gives "ImportError: cannot import name 'settings'" Jan 22, 2016
@blueyed
Copy link
Collaborator

blueyed commented Jan 22, 2016

I might have duplicated / merged too much into this issue, but it should now be only about :py[3] import jedi giving you "ImportError: cannot import name 'settings'".

See #522 for the issue with colorama 0.3.6.

@blueyed
Copy link
Collaborator

blueyed commented Jan 22, 2016

@MikeDacre
Thanks for the investigation.

Can we say that this issue is specific to Mac OS and homebrew there?

@MadWombat
Copy link
Author

Didn't someone just recently report having this problem with native python?

@blueyed
Copy link
Collaborator

blueyed commented Jan 22, 2016

native python?

I'm not sure, I would say a lot got confused with the error from colorama 0.3.6.

Maybe it's even related to this one somehow - both kept popping up at the same time (at least it seems so for me).

@blueyed
Copy link
Collaborator

blueyed commented Jan 22, 2016

I could imagine something is messing with the import system (and some error there is silenced), and you only get a non-related error.
Might be worth to check your colorama version, and/or to test with/without activating virtualenvs (which is something python-mode does by default also IIRC).

@YAtOff
Copy link

YAtOff commented Jan 27, 2016

When you try to import jedi, it eventually imports jedi.debug,
which imports colarama and calls init. And init causes AttributeError:

:py from colorama import init; init()

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/colorama/initialise.py", line 37, in init
    wrap_stream(orig_stdout, convert, strip, autoreset, wrap)
  File "/usr/local/lib/python2.7/dist-packages/colorama/initialise.py", line 76, in wrap_stream
    convert=convert, strip=strip, autoreset=autoreset)
  File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 67, in __init__
    strip = conversion_supported or (not wrapped.closed and not is_a_tty(wrapped))
AttributeError: closed

Uninstalling colorama fixes the error.

@MikeDacre
Copy link

Unfortunately I have the same error and I do not use colorama. I think there are two separate related issues here.

@MadWombat
Copy link
Author

Uninstalling colorama worked for me. But several packages I use need colorama, so I have to install it back. Any other solution?

@blueyed
Copy link
Collaborator

blueyed commented Jan 28, 2016

The colorama issue is #522. The workaround is to use 0.3.5. I have submitted a PR to fix it, but it is nor merged yet. Feedback would be appreciated there.

@MikeDacre
Copy link

OK, this issue just started happening on my linux box too:

Error: jedi-vim failed to initialize Python: jedi#setup_py_version: Vim(py3file):Traceback (most recent call last): (in function jedi#init_python[3]..<SNR>116_init_python[31]..jedi#force_py_version[2]..jedi#setup_py_version, line 18)

No idea why, I did not change my config at all, just like with my Mac. I did do a system upgrade though. Following the system upgrade, this error started happening. Very similar to with my Mac. Really bizarre. Updating all plugins has no effect, disabling all plugins except jedi-vim has no effect, removing all jedi config lines from my vimrc (going back to default config), has no effect. It is just bust.

This may be a slightly different issue though (probably not), because it seems like arch linux has changed the default vim compilation to include both python2 and 3, dynamically linked:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 13 2016 12:08:13)
Included patches: 1-1089
Compiled by Arch Linux
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   +perl/dyn        +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua/dyn         +rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
  system vimrc file: "/etc/vimrc"
    user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc        

Compiling vim myself with only python2 fixes the issue in this case. There is a slightly different sys.path issue for the python2/3 default vim in arch linux now:

['/home/dacre/.local/lib/python2.7/site-packages/bed_lookup-0.9-py2.7-linux-x86_64.egg', '/home/dacre/usr/lib/python', '/home/dacre/lib/python', '/home/dacre/tools/python', '/home/dacre/mike_tools/python', '/usr/lib/root', '/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', '/home/dacre/.local/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/gtk-2.0', '_vim_path_']

I realize that in both cases, on Mac OS and on the new arch linux vim, this problem isn't technically the fault of jedi-vim, as it works OK on other platforms, but at the same time I wonder if it is possible to improve the sys.path handling to ensure that in every case, ~/.vim/bundle/jedi-vim is the first item in the path and that ~/.vim/bundle/jedi-vim/jedi is never in the path. It is quite annoying that I now can't use jedi-vim on either my mac or linux box because of simple sys.path issues. I am going to look quickly and see if I can fix it myself somehow.

@MikeDacre
Copy link

OK, in this case, I can fix the issue by forcing python2 with let g:jedi#force_py_version = 2. If left to default with both pythons compiled in, python3 is used, and then the above error happens. Is this a known issue with python2/3 compilation?

I am debating whether this is related to the primary issue of this thread. It is that same kind of thing, jed#setup_py_version() fails at line 18 because of sys.path problems, but in this case the trigger and sys.path problem is different. If you think this is off topic I will delete these comments and open a new issue.

@davidhalter
Copy link
Owner

Hmm. So what then adds to the sys path? VIM itself?

@saurabh-hirani
Copy link

Putting in my obersrvations: For me, the issue occured after I updated pylint. That installed colorama. Post pylint update, I started getting the above error. Uninstalled and reinstalled jedi. No avail. Did a pip uninstall of colorama and things went back to normal.

@blueyed
Copy link
Collaborator

blueyed commented Feb 1, 2016

@saurabh-hirani
That is #522 then, not this issue here.

This issue is about "ImportError: cannot import name 'settings'" when trying to import jedi from inside of Vim.
#522 is solved / triaged, but this issue here is unclear.

@MikeDacre
What does :py import jedi / :py3 import jedi give you?

@saurabh-hirani
Copy link

@blueyed Ah ok - my bad.

@akhilman
Copy link

same problem on Debian Sid, vim compiled from git master.

--> vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 10 2016 14:32:02)
Included patches: 1-1297
Compiled by ildar@artstation
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +tag_binary
+arabic          +file_in_path    +mouse_sgr       +tag_old_static
+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white
+balloon_eval    +float           +mouse_urxvt     -tcl
+browse          +folding         +mouse_xterm     +terminfo
++builtin_terms  -footer          +multi_byte      +termresponse
+byte_offset     +fork()          +multi_lang      +textobjects
+channel         +gettext         -mzscheme        +title
+cindent         -hangul_input    +netbeans_intg   +toolbar
+clientserver    +iconv           +path_extra      +user_commands
+clipboard       +insert_expand   -perl            +vertsplit
+cmdline_compl   +job             +persistent_undo +virtualedit
+cmdline_hist    +jumplist        +postscript      +visual
+cmdline_info    +keymap          +printer         +visualextra
+comments        +langmap         +profile         +viminfo
+conceal         +libcall         -python          +vreplace
+cryptv          +linebreak       +python3         +wildignore
+cscope          +lispindent      +quickfix        +wildmenu
+cursorbind      +listcmds        +reltime         +windows
+cursorshape     +localmap        +rightleft       +writebackup
+dialog_con_gui  -lua             -ruby            +X11
+diff            +menu            +scrollbind      -xfontset
+digraphs        +mksession       +signs           +xim
+dnd             +modify_fname    +smartindent     +xsmp_interact
-ebcdic          +mouse           -sniff           +xterm_clipboard
+emacs_tags      +mouseshape      +startuptime     -xterm_save
+eval            +mouse_dec       +statusline      +xpm
+ex_extra        +mouse_gpm       -sun_workshop
+extra_search    -mouse_jsbterm   +syntax
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/home/ildar/.local/opt/vim/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm

:py3 import jedi yields:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/jedi/__init__.py", line 41, in <module>
    from jedi.api import Script, Interpreter, NotFoundError, set_debug_function
  File "/usr/lib/python3/dist-packages/jedi/api/__init__.py", line 16, in <module>
    from jedi.parser import Parser, load_grammar
  File "/usr/lib/python3/dist-packages/jedi/parser/__init__.py", line 21, in <module>
    from jedi.parser import tree as pt
  File "/usr/lib/python3/dist-packages/jedi/parser/tree.py", line 39, in <module>
    from jedi import cache
  File "/usr/lib/python3/dist-packages/jedi/cache.py", line 32, in <module>
    from jedi import debug
  File "/usr/lib/python3/dist-packages/jedi/debug.py", line 17, in <module>
    init()
  File "/usr/lib/python3/dist-packages/colorama/initialise.py", line 37, in init
    wrap_stream(orig_stdout, convert, strip, autoreset, wrap)
  File "/usr/lib/python3/dist-packages/colorama/initialise.py", line 76, in wrap_stream
    convert=convert, strip=strip, autoreset=autoreset)
  File "/usr/lib/python3/dist-packages/colorama/ansitowin32.py", line 67, in __init__
    strip = conversion_supported or (not wrapped.closed and not is_a_tty(wrapped))
AttributeError: 'vim.message' object has no attribute 'closed

Downgrading python3-colorama from 0.3.6-1 to 0.3.3-1 solves problem.

@blueyed
Copy link
Collaborator

blueyed commented Feb 10, 2016

@akhilman #522 then.

@Congee
Copy link

Congee commented Mar 10, 2016

upgrading colorama from 0.3.6 to 0.3.7 solves this problem

@tony
Copy link

tony commented Mar 18, 2016

I have colorama 0.3.3 in the virtualenv. However jedi seemed to care more about the colorama in my ~/.local site-packages (0.3.6)

Upgrading to 0.3.7 fixed. Just like @Congee

@blueyed
Copy link
Collaborator

blueyed commented Mar 18, 2016

Closing this issue, because it's too much of a mix with the colorama issue (#522) and (maybe?) some other one.

There's #547 for improved error messages (not yet in master as of now).

@blueyed blueyed closed this as completed Mar 18, 2016
@changliu0828
Copy link

changliu0828 commented Mar 17, 2017

I have the similar error. My system is MacOS 10.12.3.

It works well when I import Jedi in python...

`#### Jedi-vim debug information
Using Python version: 2

  • sys.version: 2.7.10 (default, Jul 30 2016, 19:40:32), [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
  • site module: /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Ver sions/2.7/lib/python2.7/site.pyc
    ERROR: the "jedi" Python module could not be imported.
    The error was: cannot import name tree
  • jedi-vim git version: 0.8.0-74-g2ee9ec6
  • jedi git submodule status: 70200861661a921016563717487c1ced9993acdb jedi (v0
    .10.0)`

@blueyed
Copy link
Collaborator

blueyed commented Mar 17, 2017

@changliu0828

The error was: cannot import name tree

Sounds like a messed-up Python installation/virtualenv.

@dendisuhubdy
Copy link

Weird it happened to me today, my Python is 3.7

@alexdetrano
Copy link

@dendisuhubdy I also had this issue happen when I upgraded via brew to python 3.7

@davidhalter
Copy link
Owner

Please refer to this comment #841 (comment)

I'm pretty sure it's an issue on brew with 3.7.

Repository owner locked as resolved and limited conversation to collaborators Jul 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests