roxma / vim-hug-neovim-rpc

EXPERIMENTAL
MIT License
218 stars 28 forks source link

Error Every time I load in vim8 (not neovim) #47

Closed chrisvacc closed 5 years ago

chrisvacc commented 5 years ago

This seems to be a very common error with vim-hug-neovim-rpc

And I believe I followed all the correct instructions:

Error:

Error detected while processing /Users/chrisvaccaro/.vimrc:
line  118:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named ‘neovim'

Even though I ran pip install pynvim and pip install neovim successfully

No module named ‘neovim’ comes from calling it from my From my .vimrc:

if !has('nvim') " Vim 8 only
    pythonx import neovim
endif

Second error:

[vim-hug-neovim-rpc] Vim(pythonx):Traceback (most recent call last):
Error detected while processing function <SNR>61_on_warmup[7]..<SNR>61_try_rnoti
fy[2]..yarp#core#try_notify[1]..yarp#core#jobstart[2]..yarp#pyx#init[13]..yarp#c
ore#serveraddr[1]..neovim_rpc#serveraddr:
line   15:
E605: Exception not caught: [vim-hug-neovim-rpc] requires `:pythonx import neovi
m` command to work
Error detected while processing function <SNR>61_on_warmup[7]..<SNR>61_try_rnoti
fy[2]..yarp#core#try_notify[1]..yarp#core#jobstart:
line    2:
E171: Missing :endif

:echo has(‘python’) returns 0 even though python in installed

Do I need to have this to point to the python location? (from .vimrc)

let g:pyenv_host_prog = '/usr/local/bin/pyenv'
let g:pip_host_prog = '/usr/local/bin/pip'
let g:python_host_prog = '/usr/local/Cellar/python@2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/bin/'
let g:python3_host_prog = '/Library/Frameworks/Python.framework/Versions/3.7/bin/python3’

let g:loaded_python_provider = 0
let g:loaded_python3_provider = 0

let $NVIM_PYTHON_LOG_FILE="/tmp/nvim_log"
let $NVIM_PYTHON_LOG_LEVEL="DEBUG"

How can I make 100% sure that the right location

also added:

if has('pythonx')
    set pyxversion=3
endif

echo neovim_rpc#serveraddr() returns /var/folders/4q/zfgdfzzzzdzzzzzdfgzgzgzzg, so i don’t think it worked right

neumachen commented 5 years ago

I can't get mine to work. :( I have pynvim installed and still it vim can't find it when importing. I'm curious if there's a way to know what directory of python vim is using.

Shougo commented 5 years ago

:echo has(‘python’) returns 0 even though python in installed

You must enable python3 interface in the first. :echo has('python3')

In the second, you must install pynvim module.

Even though I ran pip install pynvim and pip install neovim successfully

It must be pip3 install pynvim.

if !has('nvim') " Vim 8 only
    pythonx import neovim
endif

It should be:

if !has('nvim') " Vim 8 only
    pythonx import pynvim
endif
chrisvacc commented 5 years ago

This is literally the most complex setup I've ever encountered, and no one responds to threads. Time to move to Emacs.

Shougo commented 5 years ago

I have responded.

The installation is not easy. But it is not hard if you know what you do.

chrisvacc commented 5 years ago

I have responded.

The installation is not easy. But it is not hard if you know what you do.

Ahh, sorry, i didnt realize the Contributor badge... apologies.

That being said, I did post this 26 days ago.

Shougo commented 5 years ago

That being said, I did post this 26 days ago.

Unfortunately, I have not known your post.

Yes. I have contributed to the plugin and I use the plugin in my developed plugins.

roxma commented 5 years ago

You could try this command in your vim8: :pyx import pip; pip.main(['install', '--user', 'neovim'])

pythonx import neovim is required to work for using this plugin. This is not an issue. Closing.

neumachen commented 5 years ago

@roxma, @Shougo I figured this out on my MacOS machine. Basically, I am using pyenv and no matter what, unless you explicitly override the system python, running pip3 install pynvim doesn't work. But works for me now.

Just had to add the logic to initialize pyenv on my .zshrc.

roxma commented 5 years ago

@magicalbanana Vim8 links the python shared library instead of calling the executable. The link is setup at build time. You cannot override the binding without re-compiling vim8.

neumachen commented 5 years ago

You could try this command in your vim8: :pyx import pip; pip.main(['install', '--user', 'neovim'])

pythonx import neovim is required to work for using this plugin. This is not an issue. Closing.

I think you should add this command to the FAQ or something. This might come in handy to those who are not aware of Vim8 and Python.

roxma commented 5 years ago

@magicalbanana

I think you should add this command to the FAQ or something.

It has been added in the README.

suederat commented 4 years ago

my pythonx import sys; print(sys.path) is pointing to all things python2, close to header of .vimrc im saying set pyxversion=3

suederat commented 4 years ago

brew install vim fixed it, since vim ->?usr/bin/vim and after vim->/usr/local/bin/vim and has('python3') -> 1

suederat commented 4 years ago

how to fix on linux?

korsmakolnikov commented 4 years ago

Actually, I'm not able to fix this on mac os, while fixing on linux was easy enough.

echo has('python3') returns 1, and pip3 install pynvim has no effect at all.

Any one can help me?

Shougo commented 4 years ago

@korsmakolnikov What is the error? :python3 import pynvim does work in your Vim? I think pip3 python path is different with Vim's python. You need to install pynvim in your Vim's python.

dottorblaster commented 4 years ago

Actually I'm stuck too, I ran pip install pynvim and pip3 install pynvim but when I try to run the import in vim:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pynvim'

Mind that if I try to import it using my python3 shell it works

15:02:38 › python3
Python 3.7.7 (default, Mar 10 2020, 15:43:27)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pynvim
>>>
dottorblaster commented 4 years ago

@korsmakolnikov I don't know if it will be of some help but the latest vim in homebrew has python 3.8 as a dependency while I still had linked Python 3.7. I had to do brew link --overwrite python@3.8 --force then pip3 install pynvim worked to fix this issue

Edit: now it works with 3.9

joaoponceleao commented 4 years ago

@korsmakolnikov I don't know if it will be of some help but the latest vim in homebrew has python 3.8 as a dependency while I still had linked Python 3.7. I had to do brew link --overwrite python@3.8 --force then pip3 install pynvim worked to fix this issue

That was the problem. I doubt vim will depend on a keg-only python version for long though. Makes no sense to me.

A better approach is to simple type:

export PATH="/usr/local/opt/python@3.8/bin:$PATH"

followed by pip3 install pynvim

Vim will happily use the keg-only pynvim, while the global python is unaffected.

charlax commented 4 years ago

To check what Python your Vim is using you can run:

:pythonx import sys; print(sys.path)

Sure enough, mine was looking in /usr/local/opt/python@3.8/.... You can fix this using @joaoponceleao's way or this one-liner:

PATH="/usr/local/opt/python@3.8/bin:$PATH" pip3 install pynvim
tarurata commented 4 years ago

Your advice worked like a charm d(^_^o) Thanks so much.

Degete commented 4 years ago

It seems that on the new version pythonx is using the version 3.9 by default, which is a dependency.

If your python/pip version is using an older version (<3.9) and you install pyenv on them, it won't find it because it's looking for it on the site-packages of the 3.9.

The solution could be to change the default version, but if you want to keep using 3.8 or older version, you can just install pynvim on the 3.9 with the following command.

/usr/local/opt/python@3.9/bin/pip3 install pynvim

aemonge commented 2 years ago

I still can't get it set up for a Mac, with Vim.... I've tried all solutions, but still getting: :pythonx import pynvim

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pynvim'
Press ENTER or type command to continue

with :echo has('python3') => 1

And the following set up:

 aemonge   ~   pyenv versions     
  system
* 3.9.13 (set by /Users/aemonge/.python-version)
  3.10.5
 ✘ aemonge   ~   python --version
Python 3.9.13
 aemonge   ~   pip3 install pynvim
Requirement already satisfied: pynvim in ./.pyenv/versions/3.9.13/lib/python3.9/site-packages (0.4.3)
Requirement already satisfied: greenlet in ./.pyenv/versions/3.9.13/lib/python3.9/site-packages (from pynvim) (1.1.2)
Requirement already satisfied: msgpack>=0.5.0 in ./.pyenv/versions/3.9.13/lib/python3.9/site-packages (from pynvim) (1.0.4)
WARNING: You are using pip version 22.0.4; however, version 22.2.1 is available.
You should consider upgrading via the '/Users/aemonge/.pyenv/versions/3.9.13/bin/python3.9 -m pip install --upgrade pip' command.
Shougo commented 2 years ago

You need to read the output.

 aemonge   ~   pyenv versions     
  system
* 3.9.13 (set by /Users/aemonge/.python-version)
  3.10.5
 ✘ aemonge   ~   python --version
Python 3.9.13

Your pyenv(pip3) is not system.

 aemonge   ~   pip3 install pynvim
Requirement already satisfied: pynvim in ./.pyenv/versions/3.9.13/lib/python3.9/site-packages (0.4.3)
Requirement already satisfied: greenlet in ./.pyenv/versions/3.9.13/lib/python3.9/site-packages (from pynvim) (1.1.2)
Requirement already satisfied: msgpack>=0.5.0 in ./.pyenv/versions/3.9.13/lib/python3.9/site-packages (from pynvim) (1.0.4)
WARNING: You are using pip version 22.0.4; however, version 22.2.1 is available.
You should consider upgrading via the '/Users/aemonge/.pyenv/versions/3.9.13/bin/python3.9 -m pip install --upgrade pip' command.

Please read the output. You have installed pynvim to pyenv environment. Your Vim uses system python and system installed pynvim. You have not installed pip3 in System Python.

aemonge commented 2 years ago

Ohhh, got it !!!

I've done a !which python3 to understand the vim/system python path, and install pynvim vim through there, like this:

:!$(which python3) -m pip3 install pynvim

Thanks ! a ton!