13
13
14
14
Poetry is a tool for ** dependency management** and ** packaging** in Python.
15
15
It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
16
+ Poetry offers a lockfile to ensure repeatable installs, and can build your project for distribution.
16
17
17
18
18
19
## System requirements
@@ -22,27 +23,43 @@ on Linux, macOS and Windows.
22
23
23
24
## Installation
24
25
25
- {{< tabs tabTotal="3" tabID1="installing-with-the-official-installer" tabID2="installing-with-pipx" tabID3="installing-with-pip" tabName1="With the official installer" tabName2="With pipx" tabName3="With pip" >}}
26
+ {{% note %}}
27
+ If you are viewing documentation for the development branch, you may wish to install a preview or development version of Poetry.
28
+ See the ** advanced** installation instructions to use a preview or alternate version of Poetry.
29
+ {{% /note %}}
30
+
31
+ {{< tabs tabTotal="3" tabID1="installing-with-the-official-installer" tabID2="installing-with-pipx" tabID3="installing-manually" tabName1="With the official installer" tabName2="With pipx" tabName3="Manually (advanced)" >}}
26
32
27
33
{{< tab tabID="installing-with-the-official-installer" >}}
28
34
29
- Poetry provides a custom installer that will install ` poetry ` isolated
30
- from the rest of your system.
35
+ We provide a custom installer that will install Poetry in a new virtual environment to isolate it
36
+ from the rest of your system. This ensures that dependencies will not be accidentally upgraded or
37
+ uninstalled, and allows Poetry to manage its own environment.
31
38
32
39
{{< steps >}}
33
40
{{< step >}}
34
41
** Install Poetry**
35
42
36
- Install Poetry by downloading and executing the [ installation script] ( https://install.python-poetry.org ) .
43
+ The installer script is available directly at [ install.python-poetry.org] ( https://install.python-poetry.org ) ,
44
+ and is developed in [ its own repository] ( https://github.com/python-poetry/install.python-poetry.org ) .
45
+ The script can be executed directly (i.e. 'curl python') or downloaded and then executed from disk
46
+ (e.g. in a CI environment).
47
+
48
+ {{% warning %}}
49
+ The previous ` get-poetry.py ` and ` install-poetry.py ` installers are deprecated. Any installs performed
50
+ using ` get-poetry.py ` should be uninstalled and reinstalled using ` install.python-poetry.org ` to ensure
51
+ in-place upgrades are possible.
52
+ {{% /warning %}}
37
53
38
54
** Linux, macOS, Windows (WSL)**
39
55
40
56
``` bash
41
57
curl -sSL https://install.python-poetry.org | python3 -
42
58
```
59
+
43
60
{{% note %}}
44
- Note: On some systems, ` python ` may still refer to Python 2 instead of Python 3. Please always use the
45
- ` python3 ` binary to ensure the right major version of Python is used .
61
+ Note: On some systems, ` python ` may still refer to Python 2 instead of Python 3. We always suggest the
62
+ ` python3 ` binary to avoid ambiguity .
46
63
{{% /note %}}
47
64
48
65
** Windows (Powershell)**
@@ -55,60 +72,31 @@ If you have installed Python through the Microsoft Store, replace `py` with `pyt
55
72
above.
56
73
{{% /note %}}
57
74
58
- {{% note %}}
59
- Note that the installer does not support Python < 3.7.
60
- {{% /note %}}
61
-
62
- {{% warning %}}
63
- The previous ` get-poetry.py ` and ` install-poetry.py ` installers are now deprecated. If you are currently using them
64
- you should migrate to the new, supported, installer through ` https://install.python-poetry.org ` .
65
- {{% /warning %}}
66
75
{{< /step >}}
67
76
{{< step >}}
68
- ** Add Poetry to your PATH**
69
-
70
- The installer installs the ` poetry ` tool to Poetry's ` bin ` directory. This location depends on your system:
71
-
72
- - ` $HOME/.local/bin ` for Unix
73
- - ` %APPDATA%\Python\Scripts ` on Windows
77
+ ** Install Poetry (advanced)**
74
78
75
- If this directory is not on your ` PATH ` , you will need to add it manually
76
- if you want to invoke Poetry with simply ` poetry ` .
79
+ By default, Poetry is installed into a platform and user-specific directory:
77
80
78
- Alternatively, you can use the full path to ` poetry ` to use it.
79
- {{< /step >}}
80
-
81
- {{< step >}}
82
- ** Check the installation**
81
+ - ` ~/Library/Application Support/pypoetry ` on MacOS.
82
+ - ` ~/.local/share/pypoetry ` on Linux/Unix.
83
+ - ` %APPDATA%\pypoetry ` on Windows.
83
84
84
- Once Poetry is installed you can execute the following:
85
-
86
- ``` bash
87
- poetry --version
88
- ```
89
-
90
- If you see something like ` Poetry (version 1.2.0) ` then you are ready to use Poetry.
91
- {{< /step >}}
92
-
93
- {{< step >}}
94
- ** Configure the installation**
95
-
96
- By default, Poetry is installed into the user's platform-specific home directory.
97
- If you wish to change this, you may define the ` POETRY_HOME ` environment variable:
85
+ If you wish to change this, you may define the ` $POETRY_HOME ` environment variable:
98
86
99
87
``` bash
100
88
curl -sSL https://install.python-poetry.org | POETRY_HOME=/etc/poetry python3 -
101
89
```
102
90
103
91
If you want to install prerelease versions, you can do so by passing ` --preview ` option to ` install-poetry.py `
104
- or by using the ` POETRY_PREVIEW ` environment variable:
92
+ or by using the ` $ POETRY_PREVIEW` environment variable:
105
93
106
94
``` bash
107
95
curl -sSL https://install.python-poetry.org | python3 - --preview
108
96
curl -sSL https://install.python-poetry.org | POETRY_PREVIEW=1 python3 -
109
97
```
110
98
111
- Similarly, if you want to install a specific version, you can use ` --version ` option or the ` POETRY_VERSION `
99
+ Similarly, if you want to install a specific version, you can use ` --version ` option or the ` $ POETRY_VERSION`
112
100
environment variable:
113
101
114
102
``` bash
@@ -122,10 +110,45 @@ You can also install Poetry from a `git` repository by using the `--git` option:
122
110
curl -sSL https://install.python-poetry.org | python3 - --git https://github.com/python-poetry/poetry.git@master
123
111
````
124
112
{{< /step > }}
113
+ {{< step > }}
114
+ ** Add Poetry to your PATH**
115
+
116
+ The installer creates a ` poetry` wrapper in a well-known, platform-specific directory:
117
+
118
+ - ` $HOME /.local/bin` on Unix.
119
+ - ` %APPDATA%\P ython\S cripts` on Windows.
120
+
121
+ If this directory is not present in your ` $PATH ` , you can add it in order to invoke Poetry
122
+ as ` poetry` .
123
+
124
+ Alternatively, the full path to the ` poetry` binary can always be used:
125
+
126
+ - ` $POETRY_HOME /bin/poetry` if ` $POETRY_HOME ` is set.
127
+ - ` ~/Library/Application Support/pypoetry/bin/poetry` on MacOS.
128
+ - ` ~/.local/share/pypoetry/bin/poetry` on Linux/Unix.
129
+ - ` %APPDATA%\p ypoetry\S cripts\p oetry` on Windows.
130
+
131
+ {{< /step > }}
132
+ {{< step > }}
133
+ ** Use Poetry**
134
+
135
+ Once Poetry is installed and in your ` $PATH ` , you can execute the following:
136
+
137
+ ` ` ` bash
138
+ poetry --version
139
+ ` ` `
125
140
141
+ If you see something like ` Poetry (version 1.2.0)` , your install is ready to use!
142
+ {{< /step > }}
126
143
{{< step > }}
127
144
** Update Poetry**
128
145
146
+ Poetry is able to update itself when installed using the official installer.
147
+
148
+ ` ` ` bash
149
+ poetry self update
150
+ ` ` `
151
+
129
152
If you want to install pre-release versions, you can use the ` --preview` option.
130
153
131
154
` ` ` bash
@@ -140,11 +163,11 @@ poetry self update 1.2.0
140
163
` ` `
141
164
142
165
{{% warning %}}
143
- Poetry versions installed using the deprecated ` get-poetry.py` installer will not be able to use this
144
- command to update to 1.2 releases or later. Migrate to using ` https://install.python-poetry.org` or ` pipx` .
166
+ Poetry ` 1.1` series releases are not able to update in-place to ` 1.2` or newer series releases.
167
+ To migrate to newer releases, uninstall using your original install method, and then reinstall
168
+ using the [methods above]({{< ref " #installation" > }} " Installation" ).
145
169
{{% /warning %}}
146
170
{{< /step > }}
147
-
148
171
{{< step > }}
149
172
** Uninstall Poetry**
150
173
@@ -156,25 +179,61 @@ the `POETRY_UNINSTALL` environment variable before executing the installer.
156
179
curl -sSL https://install.python-poetry.org | python3 - --uninstall
157
180
curl -sSL https://install.python-poetry.org | POETRY_UNINSTALL=1 python3 -
158
181
```
159
- {{< /step >}}
160
182
183
+ {{% warning %}}
184
+ If you installed using the deprecated `get-poetry.py` script, you should use it to uninstall instead:
185
+
186
+ ```bash
187
+ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 - --uninstall
188
+ ```
189
+ {{% /warning %}}
190
+
191
+ {{< /step >}}
161
192
{{< /steps >}}
162
193
163
194
{{< /tab >}}
164
-
165
195
{{< tab tabID="installing-with-pipx" >}}
166
196
167
- Using [`pipx`](https://github.com/pypa/pipx) to install Poetry is also possible.
197
+ Using [`pipx`](https://github.com/pypa/pipx) to install Poetry is also possible and fully supported .
168
198
169
199
`pipx` is used to install Python CLI applications globally while still isolating them in virtual environments.
170
- This allows for clean upgrades and uninstalls.
200
+ `pipx` will manage upgrades and uninstalls when used to install Poetry .
171
201
172
202
{{< steps >}}
173
203
{{< step >}}
174
204
**Install Poetry**
175
205
176
206
```bash
177
207
pipx install poetry
208
+ ```
209
+ {{< /step >}}
210
+ {{< step >}}
211
+ **Install Poetry (advanced)**
212
+
213
+ `pipx` can be install different versions of Poetry, using the same syntax as pip:
214
+
215
+ ```bash
216
+ pipx install poetry==1.2.0
217
+ ```
218
+
219
+ `pipx` can also install versions of Poetry in parallel, which allows for easy testing of different or prerelease
220
+ versions. Each version is given a unique, user-specified suffix, which will be used to create a unique binary name:
221
+
222
+ ```bash
223
+ pipx install --suffix=@preview --pip-args=--pre poetry
224
+ poetry@preview --version
225
+
226
+ pipx install [email protected] poetry==1.2.0
227
+
228
+ ```
229
+
230
+ Finally, `pipx` can install any valid Python URL spec, which allows for installations of the development version from `git`,
231
+ or even the local testing of Pull Requests:
232
+
233
+ ```
234
+ pipx install --suffix @master git+https://github.com/python-poetry/poetry.git@master
235
+ pipx install --suffix @pr1234 git+https://github.com/python-poetry/poetry.git@refs/pull/1234/head
236
+
178
237
```
179
238
{{< /step >}}
180
239
{{< step >}}
@@ -194,22 +253,27 @@ pipx uninstall poetry
194
253
{{< /steps >}}
195
254
196
255
{{< /tab >}}
256
+ {{< tab tabID="installing-manually" >}}
197
257
198
- {{< tab tabID="installing-with-pip" >}}
258
+ Poetry can be installed manually using `pip` and the `venv` module. By doing so you will essentially perform the steps carried
259
+ out by the official installer. As this is an advanced installation method, these instructions are Unix-only and omit specific
260
+ examples such as installing from `git`.
199
261
200
- Using `pip` to install Poetry is possible .
262
+ The variable `$VENV_PATH` will be used to indicate the path at which the virtual environment was created .
201
263
202
264
```bash
203
- pip install --user poetry
265
+ python3 -m venv $VENV_PATH
266
+ $VENV_PATH/bin/pip install -U pip setuptools
267
+ $VENV_PATH/bin/pip install poetry
204
268
```
205
269
206
- {{% warning %}}
207
- Be aware that it will also install Poetry' s dependencies
208
- which might cause conflicts with other packages.
209
- {{% /warning %}}
270
+ Poetry will be available at `$VENV_PATH/bin/poetry` and can be invoked directly or symlinked elsewhere.
210
271
211
- {{ < /tab > }}
272
+ As this install is effectively managed by Poetry, `poetry self` commands will still be able to manipulate it.
212
273
274
+ To uninstall Poetry, simply delete the entire `$VENV_PATH` directory.
275
+
276
+ {{< /tab >}}
213
277
{{< /tabs >}}
214
278
215
279
0 commit comments