google/python-fire · critical · Error

ERROR: Python {0}.{1} is not compatible with the Google Clou

Error message

ERROR: Python {0}.{1} is not compatible with the Google Cloud SDK. {2}

What it means

fire/console/platforms.py PythonVersion.IsCompatible checks the running interpreter against the Google Cloud SDK's supported versions. If incompatible, it either writes the formatted message 'ERROR: Python {major}.{minor} is not compatible with the Google Cloud SDK...' to stderr (and returns False) or raises Error when raise_exception=True. The message includes SupportedVersionMessage describing what is supported.

Source

Thrown at fire/console/platforms.py:469

          error = ('ERROR: Python {0}.{1} is not compatible with the Google '
                   'Cloud SDK. {2}\n'
                   .format(self.version[0], self.version[1],
                           self.SupportedVersionMessage(allow_py3)))
      else:
        # Python 3 Mode
        if not allow_py3:
          error = ('ERROR: Python 3 and later is not compatible with the '
                   'Google Cloud SDK. {0}\n'
                   .format(self.SupportedVersionMessage(allow_py3)))
        elif self.version < PythonVersion.MIN_SUPPORTED_PY3_VERSION:
          error = ('ERROR: Python {0}.{1} is not compatible with the Google '
                   'Cloud SDK. {2}\n'
                   .format(self.version[0], self.version[1],
                           self.SupportedVersionMessage(allow_py3)))

    if error:
      if raise_exception:
        raise Error(error)
      sys.stderr.write(error)
      sys.stderr.write(PythonVersion.ENV_VAR_MESSAGE)
      return False

    # Warn that 2.6 might not work.
    if (self.version >= self.MIN_REQUIRED_PY2_VERSION and
        self.version < self.MIN_SUPPORTED_PY2_VERSION):
      sys.stderr.write("""\
WARNING:  Python 2.6.x is no longer officially supported by the Google Cloud SDK
and may not function correctly.  {0}
{1}""".format(self.SupportedVersionMessage(allow_py3),
              PythonVersion.ENV_VAR_MESSAGE))

    return True

View on GitHub (pinned to 716bbc23d7)

Solutions

  1. Install a supported Python version (per SupportedVersionMessage in the error).
  2. Set CLOUDSDK_PYTHON to a supported interpreter path, e.g. export CLOUDSDK_PYTHON=/usr/bin/python3.9 (or use the install's bundled python).
  3. Upgrade the Google Cloud SDK (`gcloud components update` or reinstall) to a release supporting your Python.
  4. Reinstall the SDK so its version checks and bundled runtime are consistent.

Example fix

// before
CLOUDSDK_PYTHON=/usr/local/bin/python3.12 gcloud ...   # unsupported
// after
CLOUDSDK_PYTHON=/usr/bin/python3.9 gcloud ...
Defensive patterns

Strategy: fallback

Validate before calling

import sys, subprocess
out = subprocess.run([gcloud, 'version'], capture_output=True, text=True)
if 'is not compatible with the Google Cloud SDK' in (out.stderr or ''):
    raise SystemExit('Cloud SDK needs a different Python; set CLOUDSDK_PYTHON')

Type guard

def sdk_compatible_python(major: int, minor: int, supported: set) -> bool:
    return (major, minor) in supported

Try / catch

try:
    ok = PythonVersion(...).IsCompatible(raise_exception=True)
except Error as e:
    print(f'{e} — set CLOUDSDK_PYTHON to a supported interpreter'); sys.exit(2)

Prevention

When it happens

Trigger: Running gcloud/Cloud SDK tooling with an unsupported interpreter, e.g. Python 3.12+ on an SDK install that predates it, or Python 2.7 after support was dropped; triggered on every SDK command until the interpreter is fixed.

Common situations: A system Python upgrade (distro update) silently switching the SDK's interpreter; CLOUDSDK_PYTHON env var pointing at a too-new/too-old binary; fresh machines with only unsupported Python versions installed.

Related errors


AI-assisted analysis of google/python-fire@716bbc23d7 (2026-08-28). Data as JSON: /api/errors/7d0035e7a5729a7b. Report an issue: GitHub.