2025-06-18 16:23:49 +08:00
|
|
|
# uv run
|
|
|
|
|
|
|
|
> Run a command or script in the project environment.
|
|
|
|
> More information: <https://docs.astral.sh/uv/reference/cli/#uv-run>.
|
|
|
|
|
|
|
|
- Run a Python script:
|
|
|
|
|
2025-08-31 00:06:11 +00:00
|
|
|
`uv run {{path/to/script.py}}`
|
2025-06-18 16:23:49 +08:00
|
|
|
|
|
|
|
- Run a Python module:
|
|
|
|
|
|
|
|
`uv run {{[-m|--module]}} {{module_name}}`
|
|
|
|
|
|
|
|
- Run a command with additional packages installed temporarily:
|
|
|
|
|
2025-08-31 00:06:11 +00:00
|
|
|
`uv run {{[-w|--with]}} {{package}} {{command}}`
|
2025-06-18 16:23:49 +08:00
|
|
|
|
|
|
|
- Run a script with packages from a requirements file:
|
|
|
|
|
2025-08-31 00:06:11 +00:00
|
|
|
`uv run --with-requirements {{path/to/requirements.txt}} {{path/to/script.py}}`
|
2025-06-18 16:23:49 +08:00
|
|
|
|
|
|
|
- Run in an isolated environment (no project dependencies):
|
|
|
|
|
2025-08-31 00:06:11 +00:00
|
|
|
`uv run --isolated {{path/to/script.py}}`
|
2025-06-18 16:23:49 +08:00
|
|
|
|
|
|
|
- Run without syncing the environment first:
|
|
|
|
|
|
|
|
`uv run --no-sync {{command}}`
|