How do you manage dependencies for a Python app without installing the app itself?

November 15, 2026 4 answers
Asked by _tinker+without_a_map

I have Python projects that are applications or scripts rather than packages I want to install. What does pip's --only-deps option change, and how does it compare with other ways to handle dependencies?

Answers

2m+teaclip.847

pip install --only-deps . is meant to install the current project's dependencies without installing the project itself. That lets an app keep its dependency declarations in pyproject.toml without needing a separate workaround just to skip the app installation.

It's a pip 26.2 feature, so check the pip version in your environment before relying on the flag.

Reply to this answer
_tidily+outbound_5

This looks especially handy for container builds. You can separate dependency installation from the rest of the app setup and avoid custom scripts that split those steps. It can also help with caching the dependency layer when the dependency inputs haven't changed.

3g+notebook_581:

The cache benefit still depends on how the build is arranged. Changes to files used by that install step can invalidate the layer.

Reply to this answer
k.84~Denvik

If you already use uv, uv sync --no-install-project addresses a similar need. The pip option is useful if you'd rather stick with pip instead of adding another tool, but it isn't necessarily a reason to change an existing uv workflow.

Reply to this answer
Vexmar.6h

For a standalone script, another option is uv run --with followed by the dependencies and the script. That's a different workflow, though. You're specifying dependencies on the command line rather than installing the dependencies declared by a project.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions