apache/beam · error · ImportError
Google Cloud Vision not supported for this execution…
Error message
Google Cloud Vision not supported for this execution environment (could not import google.cloud.vision).
What it means
Module-level guard in visionml.py: importing google.cloud.vision failed, so the Cloud Vision annotation transform is unavailable. This happens before any pipeline construction, typically in worker images missing the GCP extras.
Solutions
- pip install google-cloud-vision
- Or install the bundled extra: pip install 'apache_beam[gcp]'
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at sdks/python/apache_beam/ml/gcp/visionml.py:39 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/c3f80f8c0e81390f.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/ml/gcp/visionml.py:39
"""
from typing import Optional
from typing import Union
from cachetools.func import ttl_cache
from apache_beam import typehints
from apache_beam.metrics import Metrics
from apache_beam.transforms import DoFn
from apache_beam.transforms import FlatMap
from apache_beam.transforms import ParDo
from apache_beam.transforms import PTransform
from apache_beam.transforms import util
try:
from google.cloud import vision
except ImportError:
raise ImportError(
'Google Cloud Vision not supported for this execution environment '
'(could not import google.cloud.vision).')
__all__ = [
'AnnotateImage',
'AnnotateImageWithContext',
]
@ttl_cache(maxsize=128, ttl=3600)
def get_vision_client(client_options=None):
"""Returns a Cloud Vision API client."""
_client = vision.ImageAnnotatorClient(client_options=client_options)
return _client
class AnnotateImage(PTransform):
"""A ``PTransform`` for annotating images using the GCP Vision API.View on GitHub (pinned to 12126d8942)