There are multiple options to run the script.
1. Using uv run with the --project parameter.
uv run accepts a dedicated --projects parameter to run the script within the given project directory. From the documentation:
--project project
Run the command within the given project directory.
All pyproject.toml, uv.toml, and .python-version files will be discovered by walking up the directory tree from the project root, as will the project’s virtual environment (.venv).
Other command-line arguments (such as relative paths) will be resolved relative to the current working directory.
[...]
2. Using the project virtual environment explicitly.
Alternatively, you could activate the project's virtual environment explicitly.
source /path/to/your/.venv/bin/activate
With the project's virtual environment activated, running your script independently of uv should work just as well.
python3 /path/to/your/script.py
.venv)?