MENU
  

high level options for using uv:

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = [
#     "inspect_ai",
# ]
# ///
print("hello")

In VSCode you need to CTRL-SHIFT-P and select "Python: Select Interpreter" so that you can set a python version for your workspace folder. This will ensure that "go to definition" works etc.

below are more uv commands:

uv init my_app
uv init my_lib --lib
uv add requests flask
uv run main.py
# recreate .venv (usually in .gitignore) if missing... note: uv run also syncs before starting the script
uv sync
uv tree
uv python list
uv python install 3.11
# print python version for the current project
uv run python --version
# pin certain python version for current project
uv python pin 3.11

# if you create a project using the latest python version and then "uv add foo" where
# foo is a package that doesn't support the latest python version yet, it will just tell
# you that "your project requirements are unsatisfiable".

# install ruff linter globally
uv tool install ruff

# run without installing (like npx)
uv tool run ruff check
# uvx is a shortcut for "uv tool run"
uvx ruff check


# adds pyproject.toml metadata as a comment in the beginning of the .py script
ux init --script main.py --python 3.14

# to install packages from private artifactory or similar, use:
export UV_INDEX=https://intranet.server.example.com/artifactory/api/pypi/python/simple