Manage Python dependencies
Use this guide after initializing your Python project. Run the commands from the project root. If you started with a standalone script, use uv's script dependency commands instead.
Add a package
Choose a runtime dependency if your application or library needs it to run. Choose a development dependency for tools such as pytest.
uv add httpx
uv add --dev pytest
Use the packages your project actually needs. uv updates pyproject.toml and uv.lock and syncs the environment. In a workspace, pass --package and the member's project name to update that member.
Recreate the environment
When you clone a project with a committed lockfile or pull a change to it, sync without updating the resolution.
uv sync --locked
If this fails because the lockfile is stale, review the manifest change. Someone making an intentional dependency change should refresh and commit the lockfile.
Upgrade a dependency deliberately
For example, update the locked version of httpx within your declared constraints and sync the environment.
uv lock --upgrade-package httpx
uv sync --locked
Use mise run sync when you intend to upgrade the whole project's dependencies. It runs uv sync --upgrade. Review the lockfile diff, run your tests, and run the repository checks. The configured export hook can write requirements.txt when it checks the root lockfile. Include the export if your project uses and tracks it.
See uv for the files and commands in this template, and Dependabot for automated updates.