This cheat sheet helps you translate common Poetry commands to their equivalents in uv
.
While uv
aims to be a super-fast replacement for tools like pip
, pip-tools
, and virtualenv
, its scope and workflow can differ from Poetry's integrated project management. Keep in mind that uv
often focuses on environment and dependency management, potentially requiring manual edits to pyproject.toml
where Poetry might automate them.
Task | Poetry Command | uv Command |
Notes |
---|---|---|---|
Initialize Project | poetry init |
uv init |
Both create a basic pyproject.toml . Poetry's command is more interactive by default. |
Add Dependency | poetry add <package> |
uv add <package> |
Installs the package into the venv and pyproject.toml. |
Add Dev Dependency | poetry add <package> --group dev |
uv add <package> --group dev |
Installs the package and adds the package to the developer dependencies in pyproject.toml |
Remove Dependency | poetry remove <package> |
uv remove <package> |
Uninstalls the package. |
Install from Lockfile | poetry install |
uv sync --frozen |
Installs dependencies exactly as specified in the lock file . |
Install Excluding Dev | poetry install --without dev (or --no-dev pre-1.5) |
uv sync --no-dev | Installs everything exception development dependencies |
Update Lockfile | poetry lock |
uv lock |
Generates/updates the lock file based on pyproject.toml constraints without installing. |
Update All Dependencies | poetry update |
uv sync -U |
This updates the lock file to the latest allowed versions based on pyproject.toml and then
installs/syncs the environment. The -U is important to update git dependencies correctly |
Update Specific Dependency | poetry update <package> |
uv --upgrade-package <package> -o requirements.lock && uv pip sync requirements.lock |
Updates the specified package (and its dependencies) in the lock file to the latest allowed version and then syncs the environment. |
Run Command in Venv | poetry run <command> |
uv run <command> |
Executes a command within the project's virtual environment. |
Show Venv Path | poetry env info --path |
uv venv (when creating/activating) |
uv venv primarily creates or specifies the venv path. Usually, the path is simply .venv in the project root. You can also use uv run python -c "import sys; print(sys.prefix)" . |
Remove Venv | poetry env remove <python_version> (or poetry env remove /path/to/python ) |
rm -rf .venv |
uv doesn't manage named environments like Poetry. You typically just delete the .venv directory manually. |
Show Dependency Tree | poetry show --tree |
uv pip tree |
Displays installed packages and their dependencies as a tree. |
Show Installed Packages | poetry show |
uv pip list |
Lists installed packages and their versions. uv pip freeze provides output similar to pip freeze . |
Build Package | poetry build |
python -m build |
uv focuses on installation/environment and doesn't include a build frontend itself. It relies on the standard Python build package. Ensure build is installed (uv add build ). |
Publish Package | poetry publish |
twine upload dist/* |
Like building, publishing is handled by standard tools like twine after building the distributions (wheels/sdists) into the dist/ directory. Ensure twine is installed (uv pip install twine ). |
Check Project Metadata | poetry check |
(No direct equivalent) | uv doesn't have a built-in command to validate pyproject.toml content like Poetry does. You might use external linters. |
Activate Venv Shell | poetry shell |
source .venv/bin/activate (Linux/macOS).venv\Scripts\activate (Windows) |
uv doesn't provide a dedicated shell command; you use the standard virtual environment activation scripts. |
poetry.lock
. uv pip compile
commonly outputs to requirements.lock
or uv.lock
, but is configurable.uv
is primarily focused on being an extremely fast replacement for pip
, pip-tools
, and virtualenv
/venv
.