Supporting Python versions#

Like other programming languages, Python evolves with time. New features get added to the language, and others get deprecated. For more information, see Status of Python branches.

Version

PEP

Released

Security Support Ends

Status

3.11

PEP 664

03 Oct 2022

03 Oct 2027

Dev

3.10

PEP 619

04 Oct 2021

04 Oct 2026

Dev

3.9

PEP 596

05 Oct 2020

05 Oct 2025

Stable

3.8

PEP 569

14 Oct 2019

14 Oct 2024

Stable

3.7

PEP 537

27 Jun 2018

27 Jun 2023

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 setup.py with:

from setuptools import setup

[...]

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

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.6 through 3.9, your command would look like this: python_requires='>=3.6, <3.10'.

Verifying support#

The best way to validate whether a Python library supports a version of Python is by Using continuous integration. An example GitHub workflow testing Python 3.7 through Python 3.10 on Windows and Linux would start with:

 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.7', '3.8', '3.9', '3.10']
 9    steps:
10      - name: "Run tests using pytest"
11        run: pyansys/actions/test-pytest@v3
12        with:
13          python-version: ${{ matrix.os }}

The workflow would then list the tests to run.