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
2
3
4
$ pip index versions onnx_graphsurgeon
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
onnx_graphsurgeon (0.5.5)
Available versions: 0.5.5, 0.5.2

It can be working with the Python packages that are not hosted on PyPI as well.

1
2
3
4
$ pip index versions onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
onnx_graphsurgeon (0.3.27)
Available versions: 0.3.27, 0.3.26, 0.3.25, 0.3.24, 0.3.23, 0.3.22, 0.3.21, 0.3.20, 0.3.19, 0.3.18, 0.3.17, 0.3.16, 0.3.15, 0.3.14, 0.3.13, 0.3.12, 0.3.11, 0.3.10, 0.3.9, 0.3.8, 0.3.7, 0.3.6, 0.3.5, 0.3.4, 0.3.3, 0.2.7, 0.2.3

It can also be working with the additional index URLs supplied by the --extra-index-url option.

1
2
3
4
$ pip index versions onnx_graphsurgeon --extra-index-url https://pypi.ngc.nvidia.com
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
onnx_graphsurgeon (0.5.5)
Available versions: 0.5.5, 0.5.2, 0.3.27, 0.3.26, 0.3.25, 0.3.24, 0.3.23, 0.3.22, 0.3.21, 0.3.20, 0.3.19, 0.3.18, 0.3.17, 0.3.16, 0.3.15, 0.3.14, 0.3.13, 0.3.12, 0.3.11, 0.3.10, 0.3.9, 0.3.8, 0.3.7, 0.3.6, 0.3.5, 0.3.4, 0.3.3, 0.2.7, 0.2.3

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.

Author

Lei Mao

Posted on

02-10-2025

Updated on

02-10-2025

Licensed under


Comments