vim-hug-neovim-rpc icon indicating copy to clipboard operation
vim-hug-neovim-rpc copied to clipboard

Cannot get it to work

Open vimpunk opened this issue 5 years ago • 33 comments

Hello,

first of, apologies if this is not the right place to ask. I cannot for the life of me figure out how to get this plugin to work. I have vim version 8.1 with python3 support (has('pythonx') and has('python3') both return 1) and I have installed neovim via pip (both locally with the --user flag and globally with sudo to see if it changes anything), but when running :echo neovim_rpc#serveraddr(), this is what I get:

[vim-hug-neovim-rpc] failed executing: pythonx import neovim
[vim-hug-neovim-rpc] Vim(pythonx):Traceback (most recent call last):
Error detected while processing function neovim_rpc#serveraddr:
line   15:
E605: Exception not caught: [vim-hug-neovim-rpc] requires `:pythonx import neovim` command to work
Press ENTER or type command to continue

Have I perhaps missed an installation step?

Thanks in advance!

vimpunk avatar Aug 11 '18 10:08 vimpunk

Hi mandreyel

I think the reason you may be seeing this is that neovim module is not installed for the python3 version which Vim is configured to use.

how did you install vim and python?

assuming you are on a mac, I think if you install vim and python both via homebrew (and symlink to homebrew python executables in pyenv if you are using it), this could be a solution.

..or try removing python version management and rerun pip install commands using system pythons

hope that helps

frescoraja avatar Aug 14 '18 19:08 frescoraja

Hey, thanks for your response!

I completely neglected to mention my platform, which is Linux, so not using homebrew, and python came preinstalled on my system, as did vim, I believe.

However, you may have a point there. How do I check which python version vim is using [as in, which specific binary]? Also, shouldn't this be solved by having installed the neovim module with both pip and pip3, in both cases with the --user flag and without it?

Appreciate the help

vimpunk avatar Aug 15 '18 18:08 vimpunk

I am running into this issue recently. My Arch Linux configurations are all running python3 and vim 8+. I usually use the fix here, but when I try to downgrade greenlet to 0.4.10 it just blows up at me.

Any tips on how to fix it?

jparr721 avatar Aug 15 '18 18:08 jparr721

@jparr721 Thanks for linking in that issue, I must have missed it when checking for similar ones. Indeed, greenlet seems to be the culprit for me as well.

vimpunk avatar Aug 15 '18 19:08 vimpunk

Same here, running on Arch with latest vim 8+ and python3; I tried downgrading to greenlet 0.4.10 but cannot get it to install, gcc goes nuts with it and I didn't spend time trying to figure that one out. So I'm back on latest greenlet (0.4.14).

mariusmagureanu avatar Aug 26 '18 09:08 mariusmagureanu

You should try import neovim in Python3 interpreter. I think it does not work in your enviroment.

I use Manjaro Linux and vim-hug-neovim-rpc works.

Shougo avatar Aug 26 '18 09:08 Shougo

@Shougo importing neovim in a python3 interpreter does work, hence my confusion as to why it doesn't work from within vim.

vimpunk avatar Aug 26 '18 11:08 vimpunk

If so, Vim does not use the Python. You should check the Python path.

Shougo avatar Aug 26 '18 12:08 Shougo

Check the python path from within vim you're saying?

jparr721 avatar Aug 26 '18 15:08 jparr721

When I run :version python shows up at +python/dyn and +python3/dyn and yet I cannot import neovim from within vim with :python import neovim very strange...

jparr721 avatar Aug 26 '18 15:08 jparr721

You can specify Python library by pythonthreedll option.

						*'pythonthreedll'*
'pythonthreedll'	string	(default depends on the build)
			global
			{not in Vi}
			{only available when compiled with the |+python3/dyn|
			feature}
	Specifies the name of the Python 3 shared library. The default is
	DYNAMIC_PYTHON3_DLL, which was specified at compile time.
	Environment variables are expanded |:set_env|.
	This option cannot be set from a |modeline| or in the |sandbox|, for
	security reasons.

When I run :version python shows up at +python/dyn and +python3/dyn and yet I cannot import neovim from within vim with :python import neovim very strange...

And you must test :python3 import neovim instead.

Shougo avatar Aug 26 '18 15:08 Shougo

Aren't dlls a windows only thing? Or am I mistaken?

jparr721 avatar Aug 26 '18 15:08 jparr721

Also, I tested with :python3 import neovim and greenlet seems to be causing an issue when it is imported.

jparr721 avatar Aug 26 '18 15:08 jparr721

Also, I tested with :python3 import neovim and greenlet seems to be causing an issue when it is imported.

You should remove greenlet library and reinstall neovim package.

Shougo avatar Aug 26 '18 16:08 Shougo

Aren't dlls a windows only thing? Or am I mistaken?

It is not only Windows environment.

Shougo avatar Aug 26 '18 16:08 Shougo

Please research about pythonthreedll. It is used widely.

Shougo avatar Aug 26 '18 16:08 Shougo

Ahh I see now. My pythonthreedll option looks the same as yours. Also, when removing the greenlet package and doing the neovim install again, neovim just pulls greenlet into the installation.

jparr721 avatar Aug 26 '18 16:08 jparr721

installing the greenlet and neovim from the aur instead of pip3 solved the problem for me. sudo pip3 uninstall neovim sudo pip3 uninstall greenlet and then build https://aur.archlinux.org/packages/python-neovim-git/ with dependencies

i have no clue why this worked, tho.

niiine avatar Sep 04 '18 01:09 niiine

When i update my vim to 8.1 the 'import neovim' not work on vim, but works on python3 shell

lucasteles avatar Sep 14 '18 19:09 lucasteles

The solution of strahlii worked for me on Manjaro Linux for Vim 8.1 Should be added as workaround int the README for Arch/Manjaro users.

Shadowsith avatar Sep 29 '18 11:09 Shadowsith

I am getting the same problem as @lucasteles.

kujohn avatar Nov 09 '18 02:11 kujohn

You should re-build Vim8.1 with Python3 support.

Shougo avatar Nov 09 '18 02:11 Shougo

I'm on Arch Linux. Vim8.1 (built with Python3 support - vim --version).

Started off with pip3 install --user pynvim. On re-opening vim, :message shows the pythonx import neovim error.

import neovim worked on python3 shell but :python3 import neovim failed inside vim. I tried from the AUR as well, as @strahlii mentioned, but it didn't help me any. As https://github.com/roxma/vim-hug-neovim-rpc/issues/3 suggests, I tried downgrading greenlet to 0.4.10 helps, but python/gcc won't allow it. Current greenlet version 0.4.15.

Finally I did pip3 uninstall greenlet and pip3 install --user pynvim. pynvim pulled in greenlet 0.4.15 again. When I tried vim this time, no errors. I checked :python3 import neovim and no errors. It worked!! (I have no idea why.. no versions changed, but it did work)

vdraceil avatar Feb 23 '19 21:02 vdraceil

I tried @vdraceil's fix, but it didn't work for me. There's always import errors in vim.

Tanath avatar Mar 26 '19 20:03 Tanath

For anyone who still has the issue which gives something like the following when executing :python3 import neovim

ImportError: /home/roy/.local/lib/python3.6/site-packages/greenlet.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PyExc_ValueError

You should config pip to compile binary locally, and I find this on archlinux forum. Put it in ~/.config/pip/pip.conf, and reinstall greenlet.

[install]
user = yes
no-binary = :all:

roylez avatar Apr 01 '19 04:04 roylez

I'm on macOS Mojave. Vim8.1 (built with Python3 support - vim --version) env details:

% python --version
Python 3.7.1

% pyenv root
~/.anyenv/envs/pyenv

% which pip3
~/.anyenv/envs/pyenv/shims/pip3

% pip list
Package    Version
---------- -------
greenlet   0.4.10
msgpack    0.6.1
neovim     0.3.1
pip        19.0.3
pynvim     0.3.2
setuptools 39.0.1
typing     3.6.6

:echo has("python3")
1

When I run below command in vim for checking, error had happened.

:python3 import pynvim

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

What should I do? I just want to use Shougo/denite.nvim..

BTW, I adjust a command for installing pynvim. It's necessary for pip current version.

:pyx from pip._internal import main; main(['install', '--user', 'pynvim'])

kitatuba avatar Apr 01 '19 15:04 kitatuba

I don't recommend for you to use pyenv. It is difficult set up properly.

If you really need pyenv(why?), you must set pythonthreedll and g:python3_host_prog to pyenv's path.

Shougo avatar Apr 02 '19 00:04 Shougo

@roylez's solution worked for me on Arch. Thanks so much!

dnapier avatar Jun 23 '19 21:06 dnapier

I had the same issue with my install on macOS Catalina. What worked for me was to install the dependencies for each version of python/pip that I have installed. If you have multiple versions of python installed then this could possibly help you

slacker007 avatar Mar 17 '20 20:03 slacker007

I am on macOs Mojave and I have the same issue too. When trying to install pynvim with :pyx from pip._internal import main; main(['install', '--user', 'pynvim']) I get:

WARNING: pip is being invoked by an old script wrapper. This will fail in a futu
re version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the unde
rlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip
 directly.
Collecting pynvim
  Using cached pynvim-0.4.1.tar.gz (41 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/Cellar/vim/8.2.0654/bin/vim -c 'import sys, setuptools,
 tokenize; sys.argv[0] = '"'"'/private/var/folders/bl/0k_m7grj0376m4c_fgqr4_b400
00gn/T/pip-install-qih7kfib/pynvim/setup.py'"'"'; __file__='"'"'/private/var/fol
ders/bl/0k_m7grj0376m4c_fgqr4_b40000gn/T/pip-install-qih7kfib/pynvim/setup.py'"'
"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'
"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'
))' egg_info --egg-base /private/var/folders/bl/0k_m7grj0376m4c_fgqr4_b40000gn/T
/pip-install-qih7kfib/pynvim/pip-egg-info
         cwd: /private/var/folders/bl/0k_m7grj0376m4c_fgqr4_b40000gn/T/pip-insta
ll-qih7kfib/pynvim/
    Complete output (3 lines):
    VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 29 2020 01:33:22)
    Unknown option argument: "--egg-base"
    More info with: "vim -h"
    ----------------------------------------

I already tried everything. :pyx from pip._internal import main; main(['install', '--user', 'pynvim']) pip3 install pynvim let g:python3_host_prog = '/usr/local/bin/python3'

I have vim 8.2.0654 installed with hombrew.

danielrotaermel avatar May 03 '20 18:05 danielrotaermel