Skip pip+venv. uv run is the first command

The first command that actually runs the script is uv run, not python -m venv plus pip.

You built a venv and pip-installed, and the script still has not run. The first command that executes it is uv run. When the sketch needs a shared page, start a room.

Stop when uv is on PATH and uv run example.py prints Hello world. Search query: uv run first script without pip+venv.

install uvuv runHello world
uv runfirst command
--withone-shot deps
PEP 723inline header

Put uv on PATH first

  1. 1
    Standalone install

    macOS / Linux: curl -LsSf https://astral.sh/uv/install.sh | sh. Use wget if you have no curl. Windows: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex". Also brew install uv or winget install --id=astral-sh.uv -e.

  2. 2
    Confirm the binary

    In a new terminal, run uv. You should see help and a command list. After the standalone installer, uv self update works.

  3. 3
    A script with no deps

    Official example: save print("Hello world") as example.py.

  4. 4
    Run it

    uv run example.py. Success prints Hello world. uv creates the environment. Skip python -m venv and activate.

Dependencies without pip first

The scripts guide: missing packages raise ModuleNotFoundError. Add them for one invocation: uv run --with rich example.py. Pin with uv run --with 'rich>12,<13' example.py. Repeat --with for more packages.

curl -LsSf https://astral.sh/uv/install.sh | sh
uv --version
printf 'print("Hello world")\n' > example.py
uv run example.py

Declare deps in the file

uv init --script example.py --python 3.12 writes PEP 723 inline metadata. uv add --script example.py 'requests<3' 'rich' adds a # /// script TOML block. Then uv run example.py. If the required Python is missing, uv downloads it.

uv run --with rich example.py
uv init --script example.py --python 3.12
uv add --script example.py 'requests<3' 'rich'
uv run example.py

Two cases that look like you still need a venv

Project directory

A standalone script in an existing project still installs that project by default. --no-project must come before the script name.

The pip interface is still there

uv has pip-compatible commands. That is a migration path, not the shortest first run. The shortest path is uv run.

A created venv is not a successful run. First success is Hello world on stdout.

Once the command matches, put the flow on one page: guide · start a room

Do I need a system Python first?

Run uv. If the script sets requires-python, uv run searches for that version and downloads it when needed.

Does --with mix with project deps?

In a project, --with packages are added on top of project dependencies. For a script only, pass --no-project.

How do I install on Windows?

Official: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex", or winget install --id=astral-sh.uv -e.

With inline metadata, do I still need --no-project?

No. Official docs: inline script metadata ignores project dependencies even inside a project directory.

Start a room