Wednesday, March 27, 2024

Re: Help with pynvim for neovim needed

Thx Enno for the reply. I meanwhile could resolve the problem. I activated a virtual environment for Python with the help of https://python.land/virtual-environments/virtualenv#google_vignette

Here shortly the commands I entered (if somebody is looking for this problem):

being the the folder of /usr/local/Cellar

mkdir -p python/myenv
virtualenv python/myenv
created virtual environment CPython3.11.8.final.0-64 in 793ms
creator CPython3macOsBrew(dest=/usr/local/Cellar/python/myenv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/mstep/Library/Application Support/virtualenv)
added seed packages: pip==24.0, setuptools==69.1.0, wheel==0.42.0
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

source python/myenv/bin/activate

pip3 install --upgrade pynvim
Collecting pynvim
Using cached pynvim-0.5.0-py2.py3-none-any.whl.metadata (469 bytes)
Collecting msgpack>=0.5.0 (from pynvim)
Downloading msgpack-1.0.8-cp311-cp311-macosx_10_9_x86_64.whl.metadata (9.1 kB)
Collecting greenlet>=3.0 (from pynvim)
Using cached greenlet-3.0.3-cp311-cp311-macosx_11_0_universal2.whl.metadata (3.8 kB)
Using cached pynvim-0.5.0-py2.py3-none-any.whl (45 kB)
Using cached greenlet-3.0.3-cp311-cp311-macosx_11_0_universal2.whl (271 kB)
Downloading msgpack-1.0.8-cp311-cp311-macosx_10_9_x86_64.whl (87 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.0/88.0 kB 2.4 MB/s eta 0:00:00
Installing collected packages: msgpack, greenlet, pynvim
Successfully installed greenlet-3.0.3 msgpack-1.0.8 pynvim-0.5.0

/usr/local/bin/python3 -m pip install pynvim


/usr/local/Cellar/python/myenv/bin $ pip3 install --upgrade pynvim
Requirement already satisfied: pynvim in /usr/local/Cellar/python/myenv/lib/python3.11/site-packages (0.5.0)
Requirement already satisfied: msgpack>=0.5.0 in /usr/local/Cellar/python/myenv/lib/python3.11/site-packages (from pynvim) (1.0.8)
Requirement already satisfied: greenlet>=3.0 in /usr/local/Cellar/python/myenv/lib/python3.11/site-packages (from pynvim) (3.0.3)

What I did not understand, why this pynvim is under Python3.11 and not under active Python3.12. I have had to adapt my init.vim with:

let g:python3_host_prog='/usr/local/bin/python3' => let g:python3_host_prog='/usr/local/bin/python3.11'

VimR and Neovim is working now.


Thx for your patience


marek


> On 26. Mar 2024, at 10:38, Enno <enno.nagel@gmail.com> wrote:
>
> It is not clear what is to be achieved, but for Python support in Vim one should ensure that `!python3 -V`, and `:python3 import sys; print(sys.version)")` coincide. For Neovim, I'd refer to the experts at https://github.com/neovim/neovim/issues/
>
> Le lundi 25 mars 2024 à 17:55:45 UTC+1, Marek Stepanek a écrit :
> Hello all,
>
>
> could some patient soul could help me out? I am at the point to give up.
>
> macOS Sonoma 14.4 Intel (2018)
>
> Homebrew newest upgrade
>
> vimr 0.44.0
>
> I am not Python coder (old school: Perl!). So forgive me my innocence. I suppose the modul pynvim should be installed outside of Homebrew?
>
> First what is in my config-file?
>
> ~/.config/nvim/init.vim
>
> let g:python3_host_prog='/usr/local/bin/python3'
> let g:loaded_python_provider = 0
> set pyxversion=3
>
>
> In Vimr or Neovim :checkhelth I get:
>
> ## Python 3 provider (optional)
>
> - INFO: Using: g:python3_host_prog = "/usr/local/bin/python3"
> - INFO: Executable: /usr/local/bin/python3
> - ERROR: Command error (job=20, exit code 1): `'/usr/local/bin/python3' -c 'import
>
> stderr: Traceback (most recent call last): File "<string>", line 1, in <module>M
> - INFO: Python version: 3.12.2
> - INFO: pynvim version: unable to load neovim Python module
> - ERROR: pynvim is not installed.
>
> Error: unable to load neovim Python module
> - ADVICE:
>
> - Run in shell: /usr/local/bin/python3 -m pip install pynvim
>
> But this advice to install with pip (or pip3) is meanwhile deprecated. My attempts to install it, little excerpt look like this:
>
> $ which python
> python not found
>
> $ which python3
> /usr/local/bin/python3
> $ which pip3
> /usr/local/bin/pip3
>
> $ brew uninstall python3 # if I remember well with -force
> $ brew install python3
> $ ll `which python3`
> lrwxr-xr-x 1 mstep admin 42B 24 Mar 18:20 /usr/local/bin/python3@ -> ../Cellar/pyt...@3.12/3.12.2_1/bin/python3
> $ ll `which pip3`
> lrwxr-xr-x 1 mstep admin 39B 24 Mar 18:20 /usr/local/bin/pip3@ -> ../Cellar/pyt...@3.12/3.12.2_1/bin/pip3
>
> $ /usr/local/bin/python3 -m pip install pynvim
> error: externally-managed-environment
>
> $ brew install python3
> × This environment is externally managed
> ╰─> To install Python packages system-wide, try brew install
> xyz, where xyz is the package you are trying to
> install.
>
> If you wish to install a non-brew-packaged Python package,
> create a virtual environment using python3 -m venv path/to/venv.
> Then use path/to/venv/bin/python and path/to/venv/bin/pip.
>
> If you wish to install a non-brew packaged Python application,
> it may be easiest to use pipx install xyz, which will manage a
> virtual environment for you. Make sure you have pipx installed.
>
> note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
> hint: See PEP 668 for the detailed specification.
>
> Same error with:
> $ pip3 install pynvim
> $ pip3 install --upgrade pynvim
>
> I tried to copy the pynvim from python3.11 to python3.12 (don't shout on me!)
>
> $ cp -r python3.11/site-packages/pynvim python3.12/site-packages
> $ cp -r python3.11/site-packages/pynvim-0.5.0.dist-info python3.12/site-packages
>
> Ok! that means I have to create a virtual environment for python-packages!
> Where you suggest to put the python packages? What path to use for the virtualenv of python?
>
> I tried with:
>
> $ brew install pipx
> $ pipx install pynvim
> No apps associated with package pynvim or its dependencies. If you are attempting to install a library, pipx should
> not be used. Consider using pip or a similar tool instead.
>
> Please a little hint! I would be very grateful for any help
>
>
> marek
>
>
>
>
>
>
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4e1f60e4-af0e-4f69-a2d7-e159f0013c49n%40googlegroups.com.


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5166613D-059C-4D23-BA95-AF3DA7F63261%40googlemail.com.

No comments: