Python versions#

Like other programming languages, Python evolves with time. New features get added to the language, and other features get deprecated. For more information, see Status of Python versions in the Python Developer’s Guide.

Version

PEP

Released

Security support ends

Status

3.13

PEP 719

07 Oct 2024

Oct 2029

Stable

3.12

PEP 693

02 Oct 2023

Oct 2028

Stable

3.11

PEP 664

03 Oct 2022

Oct 2027

Stable

3.10

PEP 619

04 Oct 2021

Oct 2026

Stable

Consider supporting stable Python versions.

Python versions labeled as stable receive only security fixes. Versions labeled as dev are still receiving bug fixes.

Expect stable versions to be the most commonly used Python versions. Some packages like NumPy drop support for older versions of Python earlier than their end of life (EOL) as outlined in NEP 29.

You can still install an older version from PyPI using pip as your package manager. When pip is used, it downloads and installs the most recent version of the library that supports your version of Python. You can enforce a minimum-required Python version within the setup.py file with this code:

from setuptools import setup

[...]

setup(name="my_package_name", python_requires=">3.10", [...])

This helps pip to know which versions of your library support which versions of Python. You can also impose an upper limit if you’re sure you don’t support certain versions of Python. For example, if you only support Python 3.10 through 3.13, your command would look like this: python_requires='>=3.10, <3.13'.

Verify Python support#

The best way to validate whether a Python library supports a version of Python is by Continuous integration. An example GitHub workflow testing Python 3.10 through Python 3.13 on Windows and Linux would start like this:

 1jobs:
 2  tests:
 3    name: "Tests"
 4    runs-on: ${{ matrix.os }}
 5    strategy:
 6      matrix:
 7        os: [windows-latest, ubuntu-latest]
 8        python-version: ['3.10', '3.11', '3.12', '3.13']
 9    steps:
10      - name: "Run tests using pytest"
11        run: ansys/actions/test-pytest@v8
12        with:
13          python-version: ${{ matrix.os }}

The workflow would then list the tests to run.