Get Available Versions for Python Pip Package
Introduction
I have not been quite programming in Python for a while. Recently, I realized that the way I used to query the available versions of a Python package using pip install <package>==
is not working anymore for pip
version 25.0.
In this blog post, I would like to quickly document how to get the available versions of a Python package.
The Standard Approach
It turns out that pip install <package>==
was just a trick and it was never officially supported for querying the available versions of a Python package.
The standard approach is always to go to the Python Package Index (PyPI) website and search for the package you are interested in. However, this approach can have some problems if the Python package is not hosted on PyPI but somewhere else, such as https://pypi.ngc.nvidia.com
and https://download.pytorch.org/whl/cu126
.
The Pip Approach
The pip
command has a built-in command called index
that can be used to query the available versions of a Python package.
1 | $ pip index versions onnx_graphsurgeon |
It can be working with the Python packages that are not hosted on PyPI as well.
1 | $ pip index versions onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com |
It can also be working with the additional index URLs supplied by the --extra-index-url
option.
1 | $ pip index versions onnx_graphsurgeon --extra-index-url https://pypi.ngc.nvidia.com |
We noticed that there is a warning message saying that pip index
is currently an experimental command and it may be removed/changed in a future release without prior warning. However, the pip index
command will no longer be experimental once this GitHub issue is resolved. This means we can safely use the pip index
command to query the available versions of a Python package without worrying about the forward compatibility.
Get Available Versions for Python Pip Package
https://leimao.github.io/blog/Python-Pip-Package-Get-Available-Versions/