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

Cannot get it to work #36

Open
vimpunk opened this issue Aug 11, 2018 · 33 comments
Open

Cannot get it to work #36

vimpunk opened this issue Aug 11, 2018 · 33 comments

Comments

@vimpunk
Copy link

vimpunk commented Aug 11, 2018

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!

@frescoraja
Copy link

frescoraja commented Aug 14, 2018

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

@vimpunk
Copy link
Author

vimpunk commented Aug 15, 2018

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

@jparr721
Copy link

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?

@vimpunk
Copy link
Author

vimpunk commented Aug 15, 2018

@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.

@mariusmagureanu
Copy link

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).

@Shougo
Copy link
Collaborator

Shougo commented Aug 26, 2018

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.

@vimpunk
Copy link
Author

vimpunk commented Aug 26, 2018

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

@Shougo
Copy link
Collaborator

Shougo commented Aug 26, 2018

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

@jparr721
Copy link

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

@jparr721
Copy link

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...

@Shougo
Copy link
Collaborator

Shougo commented Aug 26, 2018

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.

@jparr721
Copy link

jparr721 commented Aug 26, 2018

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

@jparr721
Copy link

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

@Shougo
Copy link
Collaborator

Shougo commented Aug 26, 2018

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
Copy link
Collaborator

Shougo commented Aug 26, 2018

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

It is not only Windows environment.

@Shougo
Copy link
Collaborator

Shougo commented Aug 26, 2018

Please research about pythonthreedll. It is used widely.

@jparr721
Copy link

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.

@niiine
Copy link

niiine commented Sep 4, 2018

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.

@lucasteles
Copy link

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

@Shadowsith
Copy link

Shadowsith commented Sep 29, 2018

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.

@kujohn
Copy link

kujohn commented Nov 9, 2018

I am getting the same problem as @lucasteles.

@Shougo
Copy link
Collaborator

Shougo commented Nov 9, 2018

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

@vdraceil
Copy link

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 #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)

@Tanath
Copy link

Tanath commented Mar 26, 2019

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

@roylez
Copy link

roylez commented Apr 1, 2019

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:

@kitatuba
Copy link

kitatuba commented Apr 1, 2019

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'])

@Shougo
Copy link
Collaborator

Shougo commented Apr 2, 2019

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.

@dnapier
Copy link

dnapier commented Jun 23, 2019

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

@slacker007
Copy link

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

@danielrotaermel
Copy link

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
Copy link

Found a way to fix it. @korsmakolnikov had the solution. Thanks a lot!!! Apparently you need python 3.8 for the latest vim in homebrew.

What I did:

brew install [email protected]
pip3 install pynvim

@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 [email protected] --force then pip3 install pynvim worked to fix this issue

Originally posted by @dottorblaster in #47 (comment)

@Shougo
Copy link
Collaborator

Shougo commented May 5, 2020

@roxma I think the problem on macOS X should be documented in README.
Many users have reported.

@miron9
Copy link

miron9 commented Feb 21, 2022

My OS (MacOS) Python is 3.9 but VIM (8.2) is using 3.10. I didn't want to force VIM to use 3.9 but installation of "pynvim" from within VIM didn't work for me.

I managed to fix it by determining where is Python 3.10 installed (run in VIM):
:pythonx import sys; print(sys.path)

in my case it returned:
['/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python310.zip', '/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10', '/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload', '/ usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages', ...]

and then in BASH I located "pip3" here:
$ /usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/bin/pip3 --version
pip 21.3.1 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)

and then simply
$ /usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/bin/pip3 install pynvim

All works again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests