Poetry: Package manager

Poetry is a tool for dependency management

Patrick Rachford
1 min readFeb 1, 2023

[Poetry] 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.

Install

To install, run the following in your terminal.

curl -sSL https://install.python-poetry.org | python3

Upgrade

To upgrade, run the following in your terminal.

poetry self update

Enable tab completion

To enable tab completion with Bash, run the following in your terminal.

poetry completions bash >> ~/.bash_completion

Create a new project

To create a new project, use the newcommand followed by the project’s name.

poetry new my-project

This creates a new project.

my-project
├── pyproject.toml
├── README.md
├── my-project
│ └── __init__.py
└── tests
└── __init__.py

The pyproject.toml will look like the following.

[tool.poetry]
name = "my-project"
version = "0.1.0"
description = ""
authors = ["Your name <email@example.io>"]
readme = "README.md"
packages = [{include = "my-project"}]
[tool.poetry.dependencies]
python = "³.7"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Execute code

To execute code with Poetry, run the following command.

poetry run python your_app.py

--

--

No responses yet