2025, Oct 16 21:00

Install Python packages with uv without saving to pyproject.toml: the npm --no-save equivalent

Learn how to do a no-save install in uv: use uv pip install to test packages without editing pyproject.toml or uv.lock. Activate the target venv and experiment safely.

Trying out a Python package “just to see” shouldn’t force you to commit it to project metadata. If you’re coming from the npm world, you might be looking for an npm install --no-save equivalent in uv. There isn’t such a flag on uv add, but uv still supports a clean way to install temporarily without touching pyproject.toml or the lockfile.

Problem

You want to install a package locally to a project for a quick experiment but avoid persisting it to pyproject.toml and the lockfile. In npm that’s npm install package-name --no-save. In uv you might try to reach for uv add and hope for a similar switch, but uv add has no --no-save option.

Example of the intuitive-but-not-what-you-want approach:

uv add trial-lib

This command is designed to record dependencies, and there’s no switch to bypass saving.

What’s actually happening

uv add exists to manage dependencies in your project configuration and lockfile. There’s no documented flag to add a package without persisting it. If you only need a temporary install that doesn’t alter pyproject.toml or uv.lock, you need a different entry point that behaves like pip.

Solution

Use uv’s pip-compatible interface, which installs into the current environment without updating project dependency files:

uv pip install temp-dep

“This is a low-level interface that mimics pip behavior as closely as possible.”

If you want that installation to land in your project’s uv-managed virtual environment specifically, make sure that environment is active before running the install. Otherwise, the package will be installed into whatever environment is currently active on your shell.

source .venv/bin/activate
uv pip install temp-dep

That sequence installs temp-dep into the active venv while keeping pyproject.toml and uv.lock untouched.

Why this matters

Temporary installs are useful when you just want to poke at a tool or library without committing to it. For example, you might drop something like ruff into the current venv to try new options or rules and then move on without polluting project metadata. If you later decide the package should be part of the project, switch back to uv add to record it properly. If you forget to add a dependency you actually rely on, a CI run that depends on the lockfile will surface the discrepancy by failing due to the missing package.

Takeaways

When you need a no-save install with uv, rely on uv pip install. It gives you the quick, throwaway workflow you’re used to from pip, while leaving pyproject.toml and uv.lock as they were. Activate the intended virtual environment first if you want to target that specific venv, and use uv add only when you’re ready to commit the dependency. If you prefer to isolate experiments even further, you can also try them in a separate branch or a temporary virtual environment and discard them afterward.

The article is based on a question from StackOverflow by Rinato Fenice and an answer by STerliakov.