Supported Python versions

Cloud Composer supports Python 2 and Python 3.

To see the major.minor.patch versions of Python 2 and Python 3 used in a specific Cloud Composer image, see Cloud Composer version list.

How Python versioning works

You can create environments based on Python 2 and Python 3 in the same Google Cloud project. Each environment can use only one major Python version: Python 2 or Python 3.

You can specify the major Python version when you create a new Cloud Composer environment.

After an environment is created, you cannot change the environment's major Python version. In addition, it is not possible to switch an existing environment to a different minor Python version.

About Python 2 support

Cloud Composer supports Python 2, and will continue to do so until Airflow stops supporting it. However, Python 2 reached end-of-life on January 1, 2020, which can lead to supportability limitations for Python 2 environments.

New Airflow operators, sensors, and hooks are only developed for Python 3, which may cause connectivity options to be outdated for Python 2 environments. As such, we highly recommend migrating your DAGs to a Python 3 environment, and creating all new environments with Python 3.

How Python versions affect DAGs and dependencies

When you install Python dependencies from the Python Package Index, the environment's Python version determines which pip installs the package. For example, Python 3 uses pip3. In addition, the pip command points to pip3.

Because the Python 3 package includes Python 2, the issue of which Python interpreter to use arises (PEP 394). For Python 3 environments, the python command points to python3.

Because Python 2 is scheduled for end-of-life, we recommend that you explicitly use python2 or python3 in operators, such as BashOperator and PythonOperators.

What's next