@@ -3,17 +3,63 @@ Installation
3
3
4
4
The Neovim Python client supports Python 3.7 or later.
5
5
6
- Using pip
7
- ---------
6
+ Using uv or pipx
7
+ ----------------
8
8
9
- You can install the package without being root by adding the ``--user `` flag::
9
+ For automatic detection by Neovim, pynvim should be installed in a dedicated
10
+ Python virtual environment and the ``pynvim-python `` executable should be placed
11
+ on the ``PATH ``. The recommended approach for this is to use a tool like uv
12
+ (https://docs.astral.sh/uv/) or pipx (https://pipx.pypa.io/stable/); the
13
+ ``--upgrade `` switch ensures installation of the latest version:
10
14
11
- pip3 install --user pynvim
15
+ - Install using uv (recommended)::
12
16
13
- If you follow Neovim HEAD, make sure to upgrade ``pynvim `` when you upgrade
14
- Neovim::
17
+ uv tool install --upgrade pynvim
15
18
16
- pip3 install --upgrade pynvim
19
+ - Install using pipx::
20
+
21
+ pipx install --upgrade pynvim
22
+
23
+ **NOTE ** For Neovim before v0.12.0, set the variable ``python3_host_prog `` in
24
+ ``init.vim `` to point to ``pynvim-python ``::
25
+
26
+ let g:python3_host_prog = 'pynvim-python'
27
+
28
+ Using manually created Python virtual environment
29
+ -------------------------------------------------
30
+
31
+ Alternatively, you may manually create a Python virtual environment
32
+ (https://docs.python.org/3.13/library/venv.html)::
33
+
34
+ python3 -m venv pynvim-venv
35
+
36
+ Then install pynvim into the virtual environment; the
37
+ ``--upgrade `` switch ensures installation of the latest version::
38
+
39
+ - For Unix::
40
+
41
+ pynvim-venv/bin/python -m pip install --upgrade pynvim
42
+
43
+ - For Windows::
44
+
45
+ pynvim-venv\Scripts\python -m pip install --upgrade pynvim
46
+
47
+ Then copy the ``pynvim-python `` executable somewhere on the ``PATH ``:
48
+
49
+ - For Unix::
50
+
51
+ # Assuming `~/.local/bin` is on `PATH`:
52
+ cp pynvim-venv/bin/pynvim-python ~/.local/bin/pynvim-python
53
+
54
+ - For Windows::
55
+
56
+ REM Assuming `C:\apps` is on `PATH`:
57
+ copy pynvim-venv\Scripts\pynvim-python.exe C:\apps\pynvim-python.exe
58
+
59
+ **NOTE ** For Neovim before v0.12.0, set the variable ``python3_host_prog `` in
60
+ ``init.vim `` to point to ``pynvim-python ``::
61
+
62
+ let g:python3_host_prog = 'pynvim-python'
17
63
18
64
Install from source
19
65
-------------------
@@ -23,6 +69,70 @@ Clone the repository somewhere on your disk and enter to the repository::
23
69
git clone https://github.com/neovim/pynvim.git
24
70
cd pynvim
25
71
26
- Now you can install it on your system::
72
+ Now you can install it following the instructions above, using ``. `` instead of
73
+ ``pynvim ``; the ``--upgrade `` switch ensures installation of the latest version:
74
+
75
+ - Install from source using uv::
76
+
77
+ uv tool install --upgrade .
78
+
79
+ - Install from source using pipx::
80
+
81
+ pipx install --upgrade .
82
+
83
+ - Install from source using manually created Python virtual environment:
84
+
85
+ - Create ``pynvim-venv `` as above.
86
+
87
+ - Install:
88
+
89
+ - For Unix::
90
+
91
+ pynvim-venv/bin/python -m pip install --upgrade .
92
+
93
+ - For Windows::
94
+
95
+ pynvim-venv\Scripts\python -m pip install --upgrade .
96
+
97
+ - Copy ``pynvim-python `` executable as above.
98
+
99
+ **NOTE ** For Neovim before v0.12.0, set the variable ``python3_host_prog `` in
100
+ ``init.vim `` to point to ``pynvim-python ``::
101
+
102
+ let g:python3_host_prog = 'pynvim-python'
103
+
104
+ Upgrade pynvim when upgrading Neovim
105
+ ------------------------------------
106
+
107
+ Make sure to upgrade ``pynvim `` when you upgrade Neovim. Follow the previous
108
+ instructions; the ``--upgrade `` switch will ensure installation of the latest
109
+ version.
110
+
111
+ Explicitly choosing pynvim virtual environment
112
+ ----------------------------------------------
113
+
114
+ As an alternative to exposing ``pynvim-python `` on ``PATH ``, you may configure
115
+ Neovim to use a specific Python interpreter that has pynvim installed; this may
116
+ be useful when working on pynvim itself.
117
+
118
+ After installing into a virtual environment named ``pynvim-venv ``, add the
119
+ following into Neovim's ``init.vim `` file:
120
+
121
+ - For Unix::
122
+
123
+ let g:python3_host_prog = '/path/to/pynvim-venv/bin/python'
124
+
125
+ - For Windows::
126
+
127
+ let g:python3_host_prog = 'c:\path\to\pynvim-venv\bin\python.exe'
128
+
129
+ Installing outside of a virtual environment is deprecated
130
+ ---------------------------------------------------------
131
+
132
+ Installing into the per-user Python site package area is a deprecated practice
133
+ with recent Python versions. For example, the following command fails on Ubuntu
134
+ 24.04 with the error message ``error: externally-managed-environment ``::
135
+
136
+ pip install --user pynvim
27
137
28
- pip3 install .
138
+ Instead, always install into a virtual environment .
0 commit comments