Skip to content

Instantly share code, notes, and snippets.

@gwangjinkim
Last active April 7, 2025 09:46
Show Gist options
  • Save gwangjinkim/70b353e63492e2bdd37f24b441b128b4 to your computer and use it in GitHub Desktop.
Save gwangjinkim/70b353e63492e2bdd37f24b441b128b4 to your computer and use it in GitHub Desktop.
UV Cheatsheet
Replaces: pyenvPurposeCommand
Install a specific Python versionuv python install <version>
List available Python versionsuv python list
Use a specific Python version in a projectuv python use <version>
Automatically install the required Python versionuv run –python <version> script.py
Pin the Python version for a projectuv python pin
Replaces: venvPurposeCommand
Create a virtual environmentuv venv
Create a virtual environment with specific Python ver.uv venv –python <version>
Activate virtual environment (Linux/macOS)source .venv/bin/activate
Activate virtual environment (Windows).venv\Scripts\activate
Remove a virtual environmentuv remove
Reinstall all dependencies in the virtual environmentuv sync –reinstall
Replaces: poetryPurposeCommand
Initialize a new projectuv init <project-name>
Add a package as a dependencyuv add <package-name>
Add a dev dependencyuv add –dev <package-name>
Add a package from Gituv add git+https://github.com/user/repo.git
Remove a packageuv remove <package-name>
Lock dependencies to exact versionsuv lock
Upgrade a specific packageuv lock –upgrade-package <package-name>
Upgrade all dependenciesuv lock –upgrade
Build a Python packageuv build
Publish a package to PyPIuv publish
Replaces: pip, pipxPurposeCommand
Install a packageuv add <package-name>
Remove a packageuv remove <package-name>
Install dependencies from pyproject.tomluv sync
Install dependencies while excluding some groupsuv sync –no-group dev –no-group lint
Install dependencies from requirements.txtuv pip install -r requirements.txt
Freeze dependencies into requirements.txtuv pip freeze > requirements.txt
Generate requirements.txt from uv.lockuv export –format requirements-txt > requirements.txt
Upgrade all installed packagesuv lock –upgrade
Install CLI tools globallyuv tool install <tool-name>
List all installed toolsuv tool list
Remove a globally installed CLI tooluv tool remove <tool-name>
Upgrade all installed CLI toolsuv tool upgrade –all
Replaces: Python ToolsPurposeCommand
Run a Python script inside the virtual environmentuv run <script.py>
Run a script while automatically installing depsuv run –with <package> python script.py
Run a command inside the virtual environmentuv run – <command>
Run a one-time CLI tool without installing globallyuvx <tool-name> –version
Install a tool globallyuv tool install <tool-name>
Upgrade a specific tooluv tool upgrade <tool-name>
Upgrade all installed toolsuv tool upgrade –all
Enable shell auto-completion for uveval “$(uv generate-shell-completion bash)”
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment