Skip to content

Instantly share code, notes, and snippets.

@uraimo
Last active July 5, 2025 13:48
Show Gist options
  • Save uraimo/857ca553a85a11ab81bab5b7a54d7411 to your computer and use it in GitHub Desktop.
Save uraimo/857ca553a85a11ab81bab5b7a54d7411 to your computer and use it in GitHub Desktop.
Python UV actual quickstart

Starting a new session

If you want to start a new project:

uv init

This will create a .venv, a pyproject.toml (main project file) and uv.lock.

If the project already exists and has a requirements.txt with all the dependencies, from a freshly clone project do a uv init as above and then:

uv add -r requirements.txt

This will import all the existing dependencies in pyproject.toml.

Running your scripts

The environment created with init can be activated as usual with source .env/bin/activate (and then deactivated with deactivate) to use the local python directly, or you can simply call from now on:

  uv run <script.py> <arguments>

Adding dependencies

Add new dependencies with a specific version with:

uv add '<dependency name>==x.y.z' 

or simply

uv add <dependency name>

To keep the requirements.txt in line with the updated dependencies run uv pip freeze > requirements.txt.

Remove dependencies with uv remove <dependency name>.

Python version

A local python version can be set with:

uv python install 3.14

To list the versions available for download and the versions already installed throughout the system run:

uv python list

To change the currently selected python version, pin it:

uv python pin 3.14

And update the minimum supported version in pyproject.toml if needed.

The official documentation is available here: https://docs.astral.sh/uv/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment