Skip to content

Managing DependenciesΒΆ

To add a dependency to your project using Poetry, use:

poetry add "<package_name>@<version>"
or remove the @<version> to attempt to install the latest version of that package (it may not be compatiable, and Poetry will give you an error showing this if so).

Use the -D or -E flag with poetry add to install only to dev or extra dependencies, repsectively (these won't be required or installed when installing the package).

Additionally, you can use poetry add --dry-run "<package_name>@* to find the most recent version of a desired package that IS compatiable (without actually adding it). To then add it, use poetry add "<package_name>@<version>" again, but without the --dry-run flag, and with the version found in the verbose of the dry run.

If you want to update the dependencies to the latest compatiable versions with pyproject.toml's version constraints, especially in the case of other dependent private GitHub repositories having a new release tag version, use

poetry update

If you are manually editing the pyproject.toml file to change the configuration, you'll need to run

poetry lock --no-update
to update the poetry.lock file so that it is in sync with the new pyproject.toml file.