Closed vds2212 closed 11 months ago
This is fixed but the fix hasn't been released yet. https://github.com/neovim/pynvim/pull/534
I have tested the master branch and indeed it solves my problem.
Workaround: Until released, you can install the master version (0.5.0.devN):
python -m pip install 'pynvim @ git+https://github.com/neovim/pynvim'
Note that path to python
(you can verify with which python
) should represent the same python you'd like to use in neovim (let g:python3_host_prog = "..."
, or leave this variable to empty or "python3"
which will pick up the python on $PATH
).
pip install 'pynvim @ git+https://github.com/neovim/pynvim'
Doesn't work offline though. When will the fix be released?
I'm sorry but I'm having trouble wiht this still. After launching neoivm with my virtualenv (called pyenv
)
(pynvim) ~ > pip install 'pynvim @ git+https://github.com/neovim/pynvim'
pipi='pip install'
Collecting pynvim@ git+https://github.com/neovim/pynvim
Cloning https://github.com/neovim/pynvim to /tmp/pip-install-n0z9krus/pynvim_b42a40d5d77c41389180500b9eb5e358
Running command git clone --filter=blob:none --quiet https://github.com/neovim/pynvim /tmp/pip-install-n0z9krus/pynvim_b42a40d5d77c41389180500b9eb5e358
Resolved https://github.com/neovim/pynvim to commit 169673714fd6d9f8bf53ed5ec55b9b01be5f560e
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: msgpack>=0.5.0 in ./.pyenv/versions/pynvim/lib/python3.12/site-packages (from pynvim@ git+https://github.com/neovim/pynvim) (1.0.7)
Requirement already satisfied: greenlet>=3.0 in ./.pyenv/versions/pynvim/lib/python3.12/site-packages (from pynvim@ git+https://github.com/neovim/pynvim) (3.0.1)
Building wheels for collected packages: pynvim
Building wheel for pynvim (pyproject.toml) ... done
Created wheel for pynvim: filename=pynvim-0.5.0.dev0-py2.py3-none-any.whl size=45152 sha256=184ea39a7bbec6ab0c64a8e9b22384a8b27d5478683045894a61f7177d780299
Stored in directory: /tmp/pip-ephem-wheel-cache-5ia1gm3q/wheels/ed/e4/03/32c78f104e48c5c2f0353dcc1ef88cc58a4e8c3a21f41a3165
Successfully built pynvim
Installing collected packages: pynvim
Attempting uninstall: pynvim
Found existing installation: pynvim 0.5.0.dev0
Uninstalling pynvim-0.5.0.dev0:
Successfully uninstalled pynvim-0.5.0.dev0
Successfully installed pynvim-0.5.0.dev0 /4.5s
Launching nvim (Lunarvim, if it matters) with environment active:
:echo g:python_host_prog
/home/<user>/.pyenv/version/pynvim/bin/python
Relevant section of :checkhealth provider
:
Python 3 provider (optional) ~
- pyenv: Path: /home/slack/.pyenv/libexec/pyenv
- pyenv: Root: /home/slack/.pyenv
- WARNING No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
- WARNING Could not load Python 3:
/home/slack/.pyenv/shims/python3 is Python <string>:1: DeprecationWarning: 'pkgutil.get_loader' is deprecated and slated for removal in Python 3.14; use importlib.util.find_spec() instead
3.12 and cannot provide Python 3.
/usr/bin/python3.10 does not have the "neovim" module.
python3.9 not found in search path or not executable.
python3.8 not found in search path or not executable.
python3.7 not found in search path or not executable.
/home/slack/.pyenv/shims/python is Python <string>:1: DeprecationWarning: 'pkgutil.get_loader' is deprecated and slated for removal in Python 3.14; use importlib.util.find_spec() instead
3.12 and cannot provide Python 3.
- ADVICE:
- See :help |provider-python| for more information.
- You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim
- Executable: Not found
Python virtualenv ~
- WARNING $VIRTUAL_ENV is set to: /home/slack/.pyenv/versions/3.12.0/envs/pynvim
And its /bin directory contains: python, python3, python3-config, python3.12, python3.12-config
But $PATH yields this python executable: /home/slack/.pyenv/versions/pynvim/bin/python
And $PATH in subshells yields this python executable: /home/slack/.pyenv/versions/pynvim/bin/python
And $PATH yields this python3 executable: /home/slack/.pyenv/versions/pynvim/bin/python3
And $PATH in subshells yields this python3 executable: /home/slack/.pyenv/versions/pynvim/bin/python3
And $PATH yields this python3-config executable: Usage: /home/slack/.pyenv/versions/pynvim/bin/python3-config --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed
And $PATH in subshells yields this python3-config executable: Usage: /home/slack/.pyenv/versions/pynvim/bin/python3-config --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed
And $PATH yields this python3.12 executable: /home/slack/.pyenv/versions/pynvim/bin/python3.12
And $PATH in subshells yields this python3.12 executable: /home/slack/.pyenv/versions/pynvim/bin/python3.12
And $PATH yields this python3.12-config executable: Usage: /home/slack/.pyenv/versions/pynvim/bin/python3.12-config --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed
And $PATH in subshells yields this python3.12-config executable: Usage: /home/slack/.pyenv/versions/pynvim/bin/python3.12-config --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed
So invoking Python may lead to unexpected results.
- ADVICE:
- $PATH ambiguities arise if the virtualenv is not properly activated prior to launching Nvim. Close Nvim, activate the virtualenv, check that invoking Python from the command line launches the correct one, then relaunch Nvim.
- $PATH ambiguities in subshells typically are caused by your shell config overriding the $PATH previously set by the virtualenv. Either prevent them from doing so, or use this workaround: https://vi.stackexchange.com/a/34996
I'm not sure what I might have done wrong to have it working for everyone else and not for me, but does someone have an idea of how to fix this? If I can provide any more info that would be helpful please let me know.
@slacksystem you need to set g:python3_host_prog
, not g:python_host_prog
.
Also what's your neovim version? To support python 3.12, neovim 0.9.3 or higher is required. See neovim/neovim#25316
If neovim version is good, then in your case the python host (/home/slack/.pyenv/shims/python3
) might have pynvim 0.4.3 installed. Verify your pynvim installation:
$ /home/slack/.pyenv/shims/python3 -c "import pynvim; print(pynvim.__version__)"
0.5.0.dev0
I guess the pip
command points to the wrong python. Make sure which pip
points the same python3 in the activated virtualenv.
$ /home/slack/.pyenv/shims/python3 -m pip install 'pynvim @ git+https://github.com/neovim/pynvim'
have same issue with python 3.12.0 and pynvim/neovim
when I try the command python3 -c "import pynvim; print(pynvim.__version__)"
it shows the error: "no module found named imp".
I downgraded to python 3.11.6 and it does not have the issue, neovim opens without error. :CheckHealth
runs without python error.
Released 0.5: https://github.com/neovim/pynvim/releases/tag/0.5.0
Python 3.12 has removed support for the
imp
library and in particular for theload_module
method of that package. Thepynvim
package do not support Python 3.12 anymore.