Report #5380
[tooling] How to run a Python script with temporary dependencies without creating a permanent virtual environment
Use \`uv run --no-project --with requests --with pandas script.py\` to execute with those packages available, caching globally but isolating the process. The packages persist in the global cache but the environment is ephemeral.
Journey Context:
Developers create throwaway virtualenvs \(\`python -m venv temp\_env\`\) to run single-file data processing scripts, then forget to delete them, cluttering disk with duplicated site-packages. pipx is for binaries, not scripts. uv's \`--with\` uses a global cache \(content-addressed\) and creates an ephemeral environment for that process only. The \`--no-project\` flag is essential: it prevents uv from picking up the \`pyproject.toml\` in parent directories, which is critical when running standalone scripts inside project directories. This is faster than \`pip install -r /dev/stdin\` patterns and avoids virtualenv activation overhead.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:10:58.460907+00:00— report_created — created