Cloud Composer supports Python 2 and Python 3. Environments with different Python versions can run in the same Google Cloud project.
How versioning works
You can specify the major Python version. For the
major version you specify, Cloud Composer installs the latest supported
major.minor.patch version. The default Python version
is used if the version is unspecified.
|Major version||Minor-Patch version|
You can see the major Python version for your environment in the environment details.
Selecting a version
When you create a new Cloud Composer environment, you can select the Python version. Once created, you cannot change an environment's Python version.
Important information about Python 2 support
Cloud Composer currently 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. Additionally, the
pip command points to
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
python3. Because Python 2 is scheduled for end-of-life,
we recommend that you explicitly use
operators, such as