README
Introduction
Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Poetry offers a lockfile to ensure repeatable installs, and can build your project for distribution.
System requirements
Poetry requires Python 3.8+. It is multi-platform and the goal is to make it work equally well on Linux, macOS and Windows.
Installation
Poetry should always be installed in a dedicated virtual environment to isolate it from the rest of your system. In no case, it should be installed in the environment of the project that is to be managed by Poetry. This ensures that Poetry’s own dependencies will not be accidentally upgraded or uninstalled. (Each of the following installation methods ensures that Poetry is installed into an isolated environment.)If you are viewing documentation for the development branch, you may wish to install a preview or development version of Poetry. See the advanced installation instructions to use a preview or alternate version of Poetry.With pipxWith the official installerManually (advanced)CI recommendations
We provide a custom installer that will install Poetry in a new virtual environment and allows Poetry to manage its own environment.
Install Poetry
The installer script is available directly at install.python-poetry.org, and is developed in its own repository. The script can be executed directly (i.e. ‘curl python’) or downloaded and then executed from disk (e.g. in a CI environment).
The
install-poetry.py
installer has been deprecated and removed from the Poetry repository. Please migrate from the in-tree version to the standalone version described above.Linux, macOS, Windows (WSL)
Note: On some systems,
python
may still refer to Python 2 instead of Python 3. We always suggest thepython3
binary to avoid ambiguity.Windows (Powershell)
If you have installed Python through the Microsoft Store, replace
py
withpython
in the command above.Install Poetry (advanced)
By default, Poetry is installed into a platform and user-specific directory:
~/Library/Application Support/pypoetry
on MacOS.~/.local/share/pypoetry
on Linux/Unix.%APPDATA%\pypoetry
on Windows.
If you wish to change this, you may define the
$POETRY_HOME
environment variable:If you want to install prerelease versions, you can do so by passing the
--preview
option to the installation script or by using the$POETRY_PREVIEW
environment variable:Similarly, if you want to install a specific version, you can use
--version
option or the$POETRY_VERSION
environment variable:You can also install Poetry from a
git
repository by using the--git
option:Add Poetry to your PATH
The installer creates a
poetry
wrapper in a well-known, platform-specific directory:$HOME/.local/bin
on Unix.%APPDATA%\Python\Scripts
on Windows.$POETRY_HOME/bin
if$POETRY_HOME
is set.
If this directory is not present in your
$PATH
, you can add it in order to invoke Poetry aspoetry
.Alternatively, the full path to the
poetry
binary can always be used:~/Library/Application Support/pypoetry/venv/bin/poetry
on MacOS.~/.local/share/pypoetry/venv/bin/poetry
on Linux/Unix.%APPDATA%\pypoetry\venv\Scripts\poetry
on Windows.$POETRY_HOME/venv/bin/poetry
if$POETRY_HOME
is set.
Use Poetry
Once Poetry is installed and in your
$PATH
, you can execute the following:If you see something like
Poetry (version 1.2.0)
, your install is ready to use!Update Poetry
Poetry is able to update itself when installed using the official installer.
Especially on Windows,
self update
may be problematic so that a re-install with the installer should be preferred.If you want to install pre-release versions, you can use the
--preview
option.And finally, if you want to install a specific version, you can pass it as an argument to
self update
.Poetry
1.1
series releases are not able to update in-place to1.2
or newer series releases. To migrate to newer releases, uninstall using your original install method, and then reinstall using the methods above.Uninstall Poetry
If you decide Poetry isn’t your thing, you can completely remove it from your system by running the installer again with the
--uninstall
option or by setting thePOETRY_UNINSTALL
environment variable before executing the installer.If you installed using the deprecated
get-poetry.py
script, you should remove the path it uses manually, e.g.Also remove ~/.poetry/bin from your
$PATH
in your shell configuration, if it is present.
Enable tab completion for Bash, Fish, or Zsh
poetry
supports generating completion scripts for Bash, Fish, and Zsh. See poetry help completions
for full details, but the gist is as simple as using one of the following:
Bash
Auto-loaded (recommended)
Lazy-loaded
Fish
Zsh
You must then add the following lines in your ~/.zshrc
, if they do not already exist:
Oh My Zsh
You must then add poetry
to your plugins array in ~/.zshrc
:
prezto
You may need to restart your shell in order for these changes to take effect.
Last updated