apache/beam · error · ValueError

GCP dependencies are not installed. Cannot use DicomSearch.

Error message

GCP dependencies are not installed. Cannot use DicomSearch. Please install using 'pip install apache-beam[gcp]'.

What it means

Raised by dicom_search in apache_beam/yaml/yaml_io.py when the DicomSearch transform is used but `from apache_beam.io.gcp.healthcare.dicomio import DicomSearch` fails, meaning the GCP extra dependencies of apache-beam are not installed.

Source

Thrown at sdks/python/apache_beam/yaml/yaml_io.py:987

    - result (str): JSON-encoded list of matching DICOM resources.
    - status (str): HTTP status from the DICOM API.
    - input (str): JSON-encoded copy of the search request.

  Failed searches raise unless ``error_handling`` is set, in which case they
  are routed to the configured error output.

  Args:
    buffer_size: Number of requests to buffer before flushing.
    max_workers: Maximum number of threads used to issue requests.
    error_handling: If specified, should be a mapping giving an output into
      which to emit failed searches, as described at
      https://beam.apache.org/documentation/sdks/yaml-errors/
  """
  try:
    from apache_beam.io.gcp.healthcare.dicomio import DicomSearch
  except ImportError as exn:
    raise ValueError(
        "GCP dependencies are not installed. Cannot use DicomSearch. "
        "Please install using 'pip install apache-beam[gcp]'.") from exn

  def row_to_dict(value):
    if value is None:
      return None
    if hasattr(value, '_asdict'):
      return {k: row_to_dict(v) for k, v in value._asdict().items()}
    elif hasattr(value, 'as_dict'):
      return {k: row_to_dict(v) for k, v in value.as_dict().items()}
    elif isinstance(value, (list, tuple)):
      return [row_to_dict(v) for v in value]
    elif isinstance(value, Mapping):
      return {k: row_to_dict(v) for k, v in value.items()}
    else:
      return value

  def normalize_request(value):

View on GitHub (pinned to 12126d8942)

Solutions

  1. Run pip install 'apache-beam[gcp]' in the environment executing the pipeline.
  2. Add apache-beam[gcp] to requirements.txt/setup.py extras for the project.
  3. Confirm the import works: python -c "from apache_beam.io.gcp.healthcare.dicomio import DicomSearch".

Example fix

// before
pip install apache-beam
// after
pip install 'apache-beam[gcp]'
Defensive patterns

Strategy: validation

Validate before calling

try:
    from apache_beam.io.gcp.healthcare.dicomio import DicomSearch
except ImportError:
    raise SystemExit("run: pip install 'apache-beam[gcp]'")

Prevention

When it happens

Trigger: Using the YAML dicom_search transform with a base apache-beam install (no [gcp] extra) or in an environment where google-api-client/google-cloud-healthcare deps are absent.

Common situations: Lightweight CI/containers with apache-beam installed without extras; switching from local testing to a GCP-backed pipeline without updating requirements; missing extras in requirements.txt.

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/8f99f681305d8e2d. Report an issue: GitHub.