PyPI Package Supported Python Versions

Introduction

When I tried to install some Python packages from PyPI, I would always check the “Programming Language” under the “Classifiers” on the PyPI package page. It turns out that this information is only used for searching and browsing projects on PyPI, not for installing projects. There can be mismatches between the supported Python versions it declares and the actual supported Python versions.

In this blog post, I would like to discuss the PyPI package classifiers and the supported Python versions.

PyPI Package Supported Python Versions

We will use the onnxruntime package on PyPI as an example. To search for the package information, including the supported Python versions, typically we will go to the package page on PyPI.

For the onnxruntime version 1.20.0, we will go to the URL https://pypi.org/project/onnxruntime/1.20.0/ and check the “Programming Language” under the “Classifiers” section. In this case, we can see that the package supports Python 3.7, 3.8, 3.9, 3.10, 3.11, and 3.12. However, if we check the actual package metadata using the URL https://pypi.org/pypi/onnxruntime/1.20.0/json, from the package filename listed in the urls section, such as onnxruntime-1.20.0-cp310-cp310-macosx_13_0_universal2.whl, we could see that the package only supports Python 3.10, 3.11, 3.12, and 3.13. At least we will not be able to install the onnxruntime version 1.20.0 on Python 3.9 or lower. In fact, this is a mistake originated from the onnxruntime version 1.20.0 source code. The supported Python versions and the classifiers are inconsistent.

This problem has been fixed in the onnxruntime version 1.21.0, where the package metadata has been updated to support Python 3.10, 3.11, and 3.12 only. We can check the package page at https://pypi.org/project/onnxruntime/1.21.0/ and the package metadata at https://pypi.org/pypi/onnxruntime/1.21.0/json. Both the classifiers and the package metadata indicate that the supported Python versions are 3.10, 3.11, 3.12, and 3.13. In addition, this time, the onnxruntime version 1.21.0 PyPI package has a new section called Requires in metadata, which indicates that the onnxruntime version 1.21.0 requires Python >=3.10. This is because the python_requires field was filled with ">=3.10" in the onnxruntime version 1.21.0 source code.

PyPI Classifiers VS Python-Requires

According to the Python Packaging User Guide, the python_requires field is used for controlling the Python version compatibility of a package, whereas the classifiers field is used for searching and browsing projects on PyPI.

Although the list of classifiers is often used to declare what Python versions a project supports, this information is only used for searching and browsing projects on PyPI, not for installing projects. To actually restrict what Python versions a project can be installed on, use the requires-python argument.

Python Packaging User Guide

If the Python version is not compatible with the python_requires field, the Python package could not be built, not to mention installing it via PyPI. However, it is still possible that there are missing Python packages supported for some Python versions that are compatible with the python_requires field. For example, when new Python versions are released, the package maintainers may not build the package for the new Python versions and upload it to PyPI. So it is always a good idea to check the package metadata on PyPI using the URL https://pypi.org/pypi/package-name/version/json to see the actual supported Python versions on PyPI.

References

Author

Lei Mao

Posted on

06-15-2025

Updated on

06-15-2025

Licensed under


Comments