Registry / data / apache-beam

apache-beam

JSON →
library2.71.0pypypi✓ verified 49d ago

Apache Beam is an open-source, unified programming model for defining and executing data processing pipelines for both batch and streaming data. It offers language-specific SDKs, including Python, to construct pipelines that can run on various distributed processing backends such as Apache Flink, Apache Spark, and Google Cloud Dataflow. The library maintains an active development pace with minor releases approximately every 6 weeks, and its current version is 2.71.0.

dataworkflowgcpdevopsaws
pip install apache-beam
Install & Compatibility
Where this runs
tested against v2.74.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.950 runs
build_error
glibc
py 3.103.950 runs
installs and imports cleanly · install 29.0s · import 4.257s · 721MB
750MB installed
● package 750MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

beam
import apache_beam as beam
Standard alias for the Apache Beam SDK.
ReadFromText
from apache_beam.io import ReadFromText
WriteToText
from apache_beam.io import WriteToText
PipelineOptions
from apache_beam.options.pipeline_options import PipelineOptions

This classic WordCount example demonstrates basic Apache Beam concepts: reading data from a source (local file or GCS), applying transformations like splitting, mapping, and combining, and writing the results to an output file. Run it locally using the DirectRunner.

import re import argparse import apache_beam as beam from apache_beam.io import ReadFromText, WriteToText from apache_beam.options.pipeline_options import PipelineOptions def main(argv=None): parser = argparse.ArgumentParser() parser.add_argument( '--input', dest='input', default='gs://dataflow-samples/shakespeare/kinglear.txt', help='Input file to process.') parser.add_argument( '--output', dest='output', default='output.txt', help='Output file to write results to.') known_args, pipeline_args = parser.parse_known_args(argv) pipeline_options = PipelineOptions(pipeline_args) with beam.Pipeline(options=pipeline_options) as p: # Read the text file into a PCollection lines = p | ReadFromText(known_args.input) # Count the occurrences of each word counts = ( lines | 'Split' >> beam.FlatMap(lambda x: re.findall(r'[A-Za-z\']+', x)) | 'PairWithOne' >> beam.Map(lambda x: (x, 1)) | 'GroupAndSum' >> beam.CombinePerKey(sum) ) # Format the counts into strings output = counts | 'Format' >> beam.Map( lambda word_count: '%s: %s' % (word_count[0], word_count[1])) # Write the output output | WriteToText(known_args.output) if __name__ == '__main__': print("Running Beam WordCount pipeline locally...") main() print("Pipeline finished. Check 'output.txt' for results.")
beam --version
Debug
Known issues
breakingAs of Apache Beam 2.70.0, many Python dependencies were split into 'extras'. If your pipeline previously relied on these implicitly, you may need to explicitly install them using `pip install apache-beam[gcp,interactive,yaml,redis,hadoop,tfrecord,...]` to ensure all necessary components are present.
fix
Review your pipeline's dependencies and install Apache Beam with the appropriate extras, e.g., `pip install 'apache-beam[gcp,interactive]'`.
affects: >=2.70.0
deprecatedSupport for Python 3.9 was removed in Apache Beam 2.70.0 after Python 3.9 reached its End-of-Life in October 2025. Ensure your development and runtime environments use Python 3.10 or newer.
fix
Upgrade your Python environment to 3.10 or a later supported version (e.g., Python 3.10, 3.11, 3.12). The PyPI package requires >=3.10 for 2.71.0.
affects: >=2.70.0
gotchaThe `dill` library is no longer a required, default dependency as of Apache Beam 2.71.0. If your pipeline explicitly uses the `pickle_library=dill` pipeline option, you must manually ensure `dill==0.3.1.1` is installed in both your submission and runtime environments.
fix
If using `pickle_library=dill`, add `dill==0.3.1.1` to your `requirements.txt` or ensure it's installed in your custom container.
affects: >=2.71.0
gotchaApache Beam's distributed nature makes global state problematic. Avoid using global variables to share data across elements. Instead, leverage Beam's side inputs for read-only shared data or stateful processing primitives (`StateSpec`, `TimerSpec`) for mutable, per-key state.
fix
Refactor code to use Beam's recommended patterns for sharing data, such as side inputs or stateful `DoFn`s, which are designed for distributed execution.
affects: All versions
gotchaManaging Python pipeline dependencies can lead to 'Diamond Dependency' problems, especially when bundling `apache-beam` with other libraries or using many optional extras. Incompatible versions of shared dependencies can cause runtime errors.
fix
Define pipeline dependencies carefully using `requirements.txt` (or `setup.py` for packages). Consider using custom container images to control the exact environment and pre-install dependencies, ensuring reproducibility and avoiding conflicts.
affects: All versions
breakingInstalling Apache Beam from source requires system-level build tools (like GCC and Python development headers). This is particularly relevant in minimal environments such as Alpine Linux, where these tools are not pre-installed.
fix
Ensure your environment has the necessary build tools installed. For Alpine Linux, run `apk add build-base python3-dev`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'apache_beam'
This error occurs when the Apache Beam library is not installed in the Python environment.
fix
Install Apache Beam using pip: `pip install apache-beam`.
ImportError: cannot import name 'coder_impl'
This error arises due to an internal import issue within the Apache Beam library, often related to version mismatches or installation problems.
fix
Ensure that Apache Beam is correctly installed and up to date: `pip install --upgrade apache-beam`.
Total size of the BoundedSource objects returned by BoundedSource.split() operation is larger than the allowable limit
This error occurs when attempting to process a very large number of files in a single pipeline, exceeding the system's allowable limit.
fix
Reduce the number of files processed in a single pipeline or split the processing into smaller batches.
OSError: Invalid data stream
This error happens when the pipeline encounters a malformed or corrupted file during processing.
fix
Implement error handling mechanisms to skip or log bad records, such as using try-except blocks around file reading operations.
NameError: name 'parse_into_dict' is not defined
This error occurs when a function or variable is referenced before it has been defined or imported.
fix
Ensure that all functions and variables are properly defined and imported before they are used in the code.
Upgrade
Version history
2.74.0latest on PyPI
Audit
Dependencies
pythonrequiredApache Beam 2.71.0 requires Python 3.10 or later.
apache-beam[gcp]optionalIncludes dependencies for Google Cloud Dataflow Runner, GCS IO, BigQuery IO, etc.
apache-beam[interactive]optionalIncludes dependencies for interactive pipeline development (e.g., in notebooks).
apache-beam[tfrecord]optionalIncludes dependencies for TFRecord I/O operations.
Agent activity
103 hits · last 30 days
node
12
seranking-bot
4
ahrefsbot
3
Amazon
1
amazonbot
1
Resources