This cheatsheet lists the most commonly used commands and should be more than enough for you to get started using uv.
For more advanced use cases, check the uv docs and its guides.
Install the current packageable project in editable mode
Working with scripts π
uv init --script myscript.py
Initialise the script myscript.py
uv init --script myscript.py --python 3.X
Initialise the script myscript.py and pin it to version 3.X
uv add click --script myscript.py
Add the dependency click to the script
uv remove click --script myscript.py
Remove the dependency click from the script
uv run myscript.py
Run the script myscript.py
uv run --python 3.X myscript.py
Run the script with the given Python version
uv run --with click myscript.py
Run the script along with the click dependency
Make your script executable and add the uv shebang at the very first line of the script: #!/usr/bin/env -S uv run.
This way, you can run your script directly as ./myscript.py instead of having to write uv run myscript.py.
Manage Python versions π
uv python list
List Python versions you have installed and versions you can install
uv python install 3.X
Install Python 3.X
uv python uninstall 3.X
Uninstall Python 3.X
uv run python
Run your default Python
uv run --python 3.X python
Run Python 3.X
uv python upgrade
Upgrade your Python versions
uv python pin 3.X
Pin to a specific Python version
For old timers who don't learn new tricks π΄π΅
Become a better Python π developer, drop by drop π§
Get a daily drop of Python knowledge.
A short, effective tip to start writing better Python code: more idiomatic, more effective, more efficient, with fewer bugs.
Subscribe here.