How to list all available versions of a package with pip
Codemia Knowledge Hub ·
Run pip index versions <package> to list all available versions of a Python package. It queries the configured package index (usually PyPI) and prints every published version, which is the fastest way to see what exists before pinning, downgrading or upgrading a dependency.
pip index versions
Sample output:
The first line is the latest version; the second lists all published versions in descending order. Install the one you need explicitly:
Use python -m pip to pick the interpreter
With several Python installations, bare pip may belong to a different interpreter than you expect. python -m pip ties the command to a specific Python:
This avoids the classic "I installed the package but Python cannot find it" problem, which almost always means pip and python pointed to different interpreters.
Alternatives for older pip
pip index versions was introduced in pip 21.2 (July 2021). On older pip, or when you need more detail, use one of these.
The nonexistent-version trick
Ask for a version that does not exist:
pip cannot find it, so the error lists every version it knows about:
It works on any pip version but is a hack; prefer pip index versions when available.
The PyPI JSON API
PyPI exposes a JSON endpoint for every package, which suits scripts and CI pipelines:
For a clean list of all versions:
Because it queries PyPI directly, it always shows the public index regardless of local pip configuration.
Versions matching a constraint
--dry-run (pip 22.2+) simulates the install without changing anything.
Comparing the methods
| Method | Min pip version | Works in scripts | Shows all versions | Needs network |
pip index versions | 21.2 | Yes | Yes | Yes |
pip install ==999.999 | Any | Awkward (parse stderr) | Yes | Yes |
| PyPI JSON API | N/A (uses curl/requests) | Yes | Yes | Yes |
pip install --dry-run | 22.2 | Yes | Only matching | Yes |
Listed but not installable on your Python
Packages declare supported Python versions in their metadata, and pip enforces them at install time. A listed version can still fail with:
To see which versions fit a given Python:
If your pip lacks that flag, check the package's PyPI page: the "Programming Language" classifiers and Requires-Python metadata say exactly which interpreters are supported.
Private indexes and mirrors
pip index versions queries whatever index pip is configured to use:
- On a corporate network with a private PyPI mirror, you see only what the mirror has synced.
- If
pip.conf(orpip.inion Windows) sets a customindex-url, that index is queried instead of public PyPI.
Check the current index:
Query a specific index explicitly:
This is the quickest way to debug "why is version X missing?", which often turns out to be a mirror that has not synced yet.
Upgrading pip when index versions is missing
"No such command" means your pip is older than 21.2:
Where upgrading pip is not an option (locked-down CI images, system Python), use the ==999.999 trick or the PyPI JSON API.
Things that cause confusion
- Wrong environment.
pipandpythonfrom different environments is the most common source of confusion. Verify withwhich pipandwhich python(where pipon Windows), or usepython -m pip. - Available is not installable. The listing shows what is published, not what fits your Python version, OS or architecture.
- Private index lag. Corporate mirrors may be hours or days behind PyPI. Check the public index before assuming a new release does not exist.
- Not pinning afterward. Pin the chosen version in
requirements.txt,pyproject.tomlor a lock file so every team member and CI run uses the same one. - Pre-releases are hidden. pip hides alpha, beta and rc versions unless you pass
--pre.
Related reading
- How to list all functions in a module?
- How to list all installed packages and their versions in Python?
- How to list available regions with Boto3 Python
- How to list imported modules?
- How to list Kafka consumer group using python
- How to list only top level directories in Python?
- How to load a model from an HDF5 file in Keras?
- How to load a pickle file from S3 to use in AWS Lambda?
System design interview problems on this topic
- Design a Web Crawler: solution and walkthrough
- Design a Task Scheduler: solution and walkthrough
- Design a URL Shortener (TinyURL): solution and walkthrough
- Design an API Rate Limiter: solution and walkthrough
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.