In a project managed with uv, uv tree draws the dependency tree from the lock file. The inverted view is the one I find most useful.
uv tree --depth 1
uv tree --invert --package idna
The first command lists only your direct dependencies with their locked versions. The second answers “why is this installed at all?” by turning the tree upside down:
idna v3.20
└── requests v2.34.2
└── myproject v0.1.0
That’s how you find out a library nobody asked for comes in through requests, before you try to remove it or pin it. Add --outdated and uv also marks packages that have a newer version available, which is a quick way to see what an upgrade would touch.
uv may update the lock file before it prints, the same way uv run would. If you want to look without any chance of that, add --frozen and it reads uv.lock exactly as it is. Without a pyproject.toml there’s nothing to show, so for a plain venv with pip you’d need pip show and its Required-by line instead.
Further reading: uv tree reference