roxma / vim-hug-neovim-rpc

EXPERIMENTAL
MIT License
218 stars 28 forks source link

Vim cannot find neovim module #62

Closed hutou closed 4 years ago

hutou commented 4 years ago

Since a few days, I get the following error message when launching Vim on my (uptodate) Archlinux x86_64 :

[vim-hug-neovim-rpc] Vim(pythonx):ImportError: No module named neovim 
Error detected while processing function deoplete#enable[9]..deoplete#initialize[1]..deoplete#init#_initialize[10]..<SNR>120_ini
t_internal_variables[28]..neovim_rpc#serveraddr:
line   18:
E605: Exception not caught: [vim-hug-neovim-rpc] requires one of `:pythonx import [pynvim|neovim]` command to work

I think the problem occured after an update, either to my System (there has been a lot of python packages updated recently) or to my Vim Plugins after a PlugUpdate.

To solve the this problem, I tried different solutions found on the Web, but no luck. Finally, I uninstalled several packages pip, neovim, greenlet, ... and reinstalled neovim.

$ sudo pip3 install neovim
Collecting neovim
  Downloading https://files.pythonhosted.org/packages/78/ec/ac9905ccab8774b64c37cdff9e08db320c349eda0ae3161aebcac83e5590/neovim-0.3.1.tar.gz
Collecting pynvim>=0.3.1 (from neovim)
  Downloading https://files.pythonhosted.org/packages/94/73/9fcf169c4bf1bc6d931a1f4002b139a34950ba5804b9066ffd35fc791550/pynvim-0.4.0.tar.gz
Requirement already satisfied: msgpack>=0.5.0 in /usr/lib/python3.8/site-packages (from pynvim>=0.3.1->neovim) (0.6.2)
Collecting greenlet (from pynvim>=0.3.1->neovim)
  Downloading https://files.pythonhosted.org/packages/f8/e8/b30ae23b45f69aa3f024b46064c0ac8e5fcb4f22ace0dca8d6f9c8bbe5e7/greenlet-0.4.15.tar.gz (59kB)
     |████████████████████████████████| 61kB 2.9MB/s 
Installing collected packages: greenlet, pynvim, neovim
  Running setup.py install for greenlet ... done
  Running setup.py install for pynvim ... done
  Running setup.py install for neovim ... done
Successfully installed greenlet-0.4.15 neovim-0.3.1 pynvim-0.4.0

but without success, error remains the same !

Vim says :

:echo has('python')   --> 1
:echo has('python3')   --> 0
:echo has('pythonx')   --> 1

Please, can you help ?

My Vim version is :

$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compilé Nov  7 2019 22:30:47)
Rustines incluses : 1-2268
Compilé par Arch Linux
Énorme version avec interface graphique GTK3.
  Fonctionnalités incluses (+) ou non (-) :
+acl               -farsi             -mouse_sysmouse    -tag_any_white
+arabic            +file_in_path      +mouse_urxvt       +tcl/dyn
+autocmd           +find_in_path      +mouse_xterm       +termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
+balloon_eval      -footer            -mzscheme          +termresponse
+balloon_eval_term +fork()            +netbeans_intg     +textobjects
+browse            +gettext           +num64             +textprop
++builtin_terms    -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     +perl/dyn          +toolbar
+cindent           +job               +persistent_undo   +user_commands
+clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           +python/dyn        +visual
+cmdline_info      +libcall           +python3/dyn       +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          +ruby/dyn          +wildmenu
+cursorbind        +lua/dyn           +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con_gui    +mksession         +smartindent       +X11
+diff              +modify_fname      +sound             -xfontset
+digraphs          +mouse             +spell             +xim
+dnd               +mouseshape        +startuptime       -xpm
-ebcdic            +mouse_dec         +statusline        +xsmp_interact
+emacs_tags        +mouse_gpm         -sun_workshop      +xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          +mouse_netterm     +tag_binary        
+extra_search      +mouse_sgr         -tag_old_static    
         fichier vimrc système : "/etc/vimrc"
     fichier vimrc utilisateur : "$HOME/.vimrc"
 2me fichier vimrc utilisateur : "~/.vim/vimrc"
      fichier exrc utilisateur : "$HOME/.exrc"
        fichier gvimrc système : "/etc/gvimrc"
    fichier gvimrc utilisateur : "$HOME/.gvimrc"
2me fichier gvimrc utilisateur : "~/.vim/gvimrc"
 fichier de valeurs par défaut : "$VIMRUNTIME/defaults.vim"
          fichier menu système : "$VIMRUNTIME/menu.vim"
               $VIM par défaut : "/usr/share/vim"
Compilation : gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi-3.2.1/include -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread  -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -D_REENTRANT  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Édition de liens : gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl    -lcanberra  -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/5.30/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm  
roxma commented 4 years ago

You need to rebuild vim with python3 support.

roxma commented 4 years ago

Have you tried pacman -S python-pynvim instead of sudo pip3 install neovim?

hutou commented 4 years ago

Yes, I uninstalled with pip3, then reinstalled with pacman without success. I'll try to rebuild vim, but It seems strange to me to have to do it to get a plugin working. Thanks anyway NB. vim --version show that python3/dyn is included.

Shougo commented 4 years ago

@hutou Please read :help has-python.

                            *has-python*
You can test what Python version is available with: >
    if has('python')
      echo 'there is Python 2.x'
    endif
    if has('python3')
      echo 'there is Python 3.x'
    endif

Note however, that when Python 2 and 3 are both available and loaded
dynamically, these has() calls will try to load them.  If only one can be
loaded at a time, just checking if Python 2 or 3 are available will prevent
the other one from being available.

To avoid loading the dynamic library, only check if Vim was compiled with
python support: >
    if has('python_compiled')
      echo 'compiled with Python 2.x support'
      if has('python_dynamic')
        echo 'Python 2.x dynamically loaded'
      endif
    endif
    if has('python3_compiled')
      echo 'compiled with Python 3.x support'
      if has('python3_dynamic')
        echo 'Python 3.x dynamically loaded'
      endif
    endif

This also tells you whether Python is dynamically loaded, which will fail if
the runtime library cannot be found.

I think Python2 is loaded before Python3 in your environment. So, Python2 is used and pynvim module is not installed in Python2.

You need to set python3 manually.

set pyxversion=3
Shougo commented 4 years ago

NB. vim --version show that python3/dyn is included.

It means, you can load Python2 or Python3. It is not both.

hutou commented 4 years ago

Problem solved, finally, by disabling the brookhong/DBGPavim plugin ! After that, I had yet the following error message :

[vim-hug-neovim-rpc] rpc method [nvim_set_client_info] not implemented in pythonx/neovim_rpc_methods.py.

but a PlugUpdate solved it too ! Everything is Ok, now. Thanks

Shougo commented 4 years ago

The issue should be closed

bhaskarnn9 commented 4 years ago

@hutou Hi. I have same error. how did you solve it?

bhaskarnn9 commented 4 years ago

~ vim --version | grep +python +comments +libcall +python/dyn +visualextra

vim --version  ✔  09:08:41  VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 13 2019 14:45:40) Included patches: 1-503, 505-680, 682-1312 Compiled by root@apple.com Normal version without GUI. Features included (+) or not (-): +acl +extra_search -mouse_netterm -tag_old_static -arabic -farsi +mouse_sgr -tag_any_white +autocmd +file_in_path -mouse_sysmouse -tcl +autochdir +find_in_path -mouse_urxvt -termguicolors -autoservername +float +mouse_xterm +terminal -balloon_eval +folding +multi_byte +terminfo -balloon_eval_term -footer +multi_lang +termresponse -browse +fork() -mzscheme +textobjects +builtin_terms -gettext +netbeans_intg +textprop +byte_offset -hangul_input +num64 +timers +channel +iconv +packages +title +cindent +insert_expand +path_extra -toolbar -clientserver +job -perl +user_commands -clipboard +jumplist +persistent_undo -vartabs +cmdline_compl -keymap +postscript +vertsplit +cmdline_hist +lambda +printer +virtualedit +cmdline_info -langmap -profile +visual +comments +libcall +python/dyn +visualextra -conceal +linebreak -python3 +viminfo +cryptv +lispindent +quickfix +vreplace +cscope +listcmds +reltime +wildignore +cursorbind +localmap -rightleft +wildmenu +cursorshape -lua +ruby/dyn +windows +dialog_con +menu +scrollbind +writebackup +diff +mksession +signs -X11 +digraphs +modify_fname +smartindent -xfontset -dnd +mouse +startuptime -xim -ebcdic -mouseshape +statusline -xpm -emacs_tags -mouse_dec -sun_workshop -xsmp +eval -mouse_gpm +syntax -xterm_clipboard +ex_extra -mouse_jsbterm +tag_binary -xterm_save system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" defaults file: "$VIMRUNTIME/defaults.vim" fall-back for $VIM: "/usr/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Linking: gcc -L/usr/local/lib -o vim -lm -lncurses -liconv -framework Cocoa

Shougo commented 4 years ago

Please read whole discussion.

Shougo commented 4 years ago

You need to install Python3 enabled Vim.

bhaskarnn9 commented 4 years ago

@Shougo --> Please read whole discussion. Sorry, I am a newbie, although I have read a couple of times, I couldn't get a sense of what needs to be done.

obersvations: import pynvim fails in Python 2.7 shell where as It is already installed in 3.7

Looks like I need to : set pyxversion=3

But I do not know how to enable that.

--> You need to install Python3 enabled Vim. Can you please guide me how to achieve this. Thanks a lot in advance.

Shougo commented 4 years ago

You should build Vim or install Vim by homebrew.

Shougo commented 4 years ago

Apple build Vim seems not enabled Python3 support.

bhaskarnn9 commented 4 years ago

Sure I'll try that and post my observations. Thanks.