poetry commands cheatsheet.
Create projects, add dependencies, manage virtual environments, and build and publish — the Poetry commands you reach for every day. Tap to copy.
poetry new <name>Scaffold a new project with the standard layoutpoetry initCreate a pyproject.toml interactively in the current folderpoetry installInstall dependencies from pyproject.toml and poetry.lockpoetry install --only mainInstall only the main dependencies, skipping dev groupspoetry install --no-devInstall without dev dependencies (Poetry 1.x)poetry add <pkg>Add a package and install itpoetry add <pkg>@^1.2Add a package with a version constraintpoetry add --group dev <pkg>Add a package to the dev dependency grouppoetry remove <pkg>Remove a package and update the lockfilepoetry updateUpdate dependencies to the latest allowed versionspoetry lockResolve dependencies and refresh poetry.lockpoetry run <cmd>Run a command inside the project's virtualenvpoetry shellSpawn a shell within the virtual environmentpoetry env infoShow information about the active environmentpoetry env use python3.11Use a specific Python version for the venvpoetry env listList the virtualenvs for the projectpoetry buildBuild source and wheel distributionspoetry publishUpload the package to PyPIpoetry version patchBump the patch version in pyproject.tomlpoetry version minorBump the minor version in pyproject.tomlpoetry version majorBump the major version in pyproject.tomlpoetry checkValidate the pyproject.toml configurationpoetry showList installed packagespoetry show --treeShow the dependency treepoetry show --outdatedList packages with newer versions availablepoetry --versionPrint the installed Poetry versionWhat Poetry actually does
Poetry is a dependency manager and packaging tool for Python that ties everything into a single file: pyproject.toml. It lists your dependencies, records project metadata, and replaces the older scatter of requirements.txt, setup.py and setup.cfg. When you clone a project, a single poetry install reads that file, resolves a consistent set of versions, writes them to poetry.lock, and installs them into a dedicated virtual environment — no manual venv juggling required.
Adding dependencies the right way
Adding packages has a few flavours worth understanding. poetry add <pkg> adds a runtime dependency your app needs and installs it immediately. Pin a range with poetry add <pkg>@^1.2 when you care about the version. Tools you only need while developing — test runners, linters, formatters — belong in a group: poetry add --group dev <pkg>. Every add updates both pyproject.toml and the lockfile so the change is reproducible for everyone on the team.
Environments and running code
Poetry creates and manages a virtual environment for each project so your global Python stays clean. Run a one-off command inside it with poetry run <cmd> — for example poetry run pytest — or open an interactive subshell with poetry shell. Point the project at a specific interpreter using poetry env use python3.11, and inspect what you're working with via poetry env info and poetry env list.
Building and publishing
When it's time to ship, poetry build produces source and wheel distributions and poetry publish uploads them to PyPI. Bump the version first with poetry version patch (or minor / major), and run poetry check to validate your pyproject.toml before you release. These pair naturally with the Python commands for running your code and the Git commands for version control.