/commands/pip/pip-show-package-version
pip show package: check the installed version of a Python package
- tool
- pip
- versions
- pip 20+
- os
- any
pip show requests prints the installed version of a package together with its summary, license, install location, the packages it requires and the installed packages that require it. When the package is not installed it prints WARNING: Package(s) not found and exits with code 1. Run it as python -m pip show to be sure you query the same Python that runs your code.
Show one package
uv run -q --no-project --python 3.13 --with pip==25.2 --with requests==2.32.3 \
python -m pip show --disable-pip-version-check requests | grep -E "^(Name|Version|Requires|Required-by):"Output
Name: requests Version: 2.32.3 Requires: certifi, charset-normalizer, idna, urllib3 Required-by:
The example creates a throwaway environment with uv that contains pip and requests; in your own environment the command is pip show requests. Requires lists the direct dependencies of requests, and Required-by is empty because nothing else installed depends on it. The full output also has Location, the site-packages folder the package lives in, which tells you which environment you looked at.
Missing package and exit code
uv run -q --no-project --python 3.13 --with pip==25.2 \
python -m pip show --disable-pip-version-check nosuchpackageOutput · exit 1
WARNING: Package(s) not found: nosuchpackage
Because the exit code is 1, pip show pkg > /dev/null 2>&1 || pip install pkg is a simple "install if missing" check in shell scripts.
Other ways to get the version
| Command | What it prints |
|---|---|
| pip show requests | Version, location, Requires and Required-by |
| pip show -f requests | Also every file the package installed |
| pip show requests flask | Several packages, separated by --- |
| pip list | Every installed package with its version, as a table |
| pip freeze | grep -i requests | The name==version line (findstr /i on Windows cmd) |
| python -c "import importlib.metadata as m; print(m.version('requests'))" | Only the version, from inside Python |
| pip index versions requests | Versions available on the index (experimental command) |
Pitfalls
- Several Pythons.
pipon PATH may belong to another interpreter thanpython. Comparepip --version(it prints the Python it belongs to) withpython --version, or always usepython -m pip. - Distribution name vs import name.
pip showtakes the name you install (pyyaml,scikit-learn,pillow), not the module you import (yaml,sklearn,PIL). Names are case-insensitive, and-,_and.are treated alike. - Installed but not importable. If
pip showfinds the package butimportfails with ModuleNotFoundError, the code runs with a different interpreter or virtual environment.
How to confirm it worked
Version: is the version Python will import from that environment. Cross-check with the importlib.metadata one-liner above using the interpreter that runs your application; both must print the same number.
FAQ
pip show says the package is not found, but import works. Why?
The pip you ran belongs to a different Python than the one that runs your code. Use python -m pip show package with the same python you use to run the program, and the answer will match.
How do I check a version from inside Python?
Use importlib.metadata.version('requests'), available since Python 3.8. Many packages also have a __version__ attribute, but not all, and it is not guaranteed to match the installed metadata.
How do I see which versions of a package exist on PyPI?
pip index versions requests lists the versions available on the index (the command is marked experimental in pip's documentation).