Google APIs Common Protos

raw JSON →
1.73.1 verified Tue May 12 auth: no python install: verified quickstart: verified

The 'googleapis-common-protos' library provides common protocol buffer types used across various Google APIs. The current version is 1.73.1, released on March 28, 2026. The library is actively maintained with regular updates to ensure compatibility and feature enhancements.

pip install googleapis-common-protos
error ModuleNotFoundError: No module named 'google.protobuf'
cause The `protobuf` library, which `googleapis-common-protos` depends on for serialization and deserialization of structured data, is not installed or not correctly recognized in your Python environment.
fix
Install the protobuf package: pip install protobuf (or pip install googleapis-common-protos which will install protobuf as a dependency). Consider using a virtual environment.
error ImportError: cannot import name 'descriptor_pb2'
cause This error typically occurs when the `protobuf` runtime library's generated Python files (`_pb2.py`), including `descriptor_pb2.py`, are either not properly built, corrupted, or cannot be found by Python, often due to an incomplete or problematic `protobuf` installation or a namespace conflict.
fix
Ensure protobuf is correctly installed. It often helps to reinstall both packages in a clean virtual environment: pip uninstall protobuf googleapis-common-protos followed by pip install googleapis-common-protos.
error ModuleNotFoundError: No module named 'google.api'
cause This specific import error, particularly when trying to import a `_pb2` file (e.g., `distribution_pb2`) from `google.api`, can arise from version conflicts between `googleapis-common-protos` (especially versions 1.62 or later) and older `protobuf` versions, or when installing with `setup.py` instead of `pip`, which can interfere with proper namespace package creation.
fix
Ensure both googleapis-common-protos and protobuf are up-to-date and installed using pip to resolve potential namespace issues: pip install --upgrade googleapis-common-protos protobuf.
error Import "google/api/annotations.proto" was not found or had errors.
cause When using `protoc` (the Protocol Buffer compiler) to compile your `.proto` files that import common Google API protos (like `google/api/annotations.proto`), `protoc` cannot locate the necessary `.proto` source files. This can happen if the `googleapis-common-protos` Python package was installed without its `.proto` files (an issue in some older versions) or if the `--proto_path` argument is not correctly configured to point to the directory containing these Google API `.proto` definitions.
fix
You need to provide protoc with the path to the google/api .proto files. This often involves obtaining the googleapis repository (e.g., from GitHub) and including its path: protoc -I. -I/path/to/downloaded/googleapis --python_out=. my_service.proto (where /path/to/downloaded/googleapis contains the google/api directory).
breaking Version 1.67.0 removed .proto files from wheels, causing issues for users relying on these files for building Python Protobuf bindings.
fix Pin to 'googleapis-common-protos<1.67.0' or ensure that your build process does not depend on the presence of .proto files in the package.
breaking Incompatibility with 'protobuf' versions 4.21.5 and above, leading to import errors in dependent packages.
fix Downgrade 'protobuf' to a version below 4.21.5 to maintain compatibility.
gotcha Importing modules directly without the 'from' syntax may lead to import errors due to module resolution issues.
fix Use the 'from' syntax for imports, e.g., 'from google.rpc import error_details_pb2'.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.15s 20.9M
3.10 slim (glibc) - - 0.06s 22M
3.11 alpine (musl) - - 0.51s 23.2M
3.11 slim (glibc) - - 0.07s 24M
3.12 alpine (musl) - - 0.42s 15.1M
3.12 slim (glibc) - - 0.08s 16M
3.13 alpine (musl) - - 0.39s 14.7M
3.13 slim (glibc) - - 0.06s 16M
3.9 alpine (musl) - - 0.10s 20.4M
3.9 slim (glibc) - - 0.04s 21M

This example demonstrates how to create, serialize, and deserialize a common error detail message using the 'googleapis-common-protos' library.

from google.rpc import error_details_pb2

# Create an instance of a common error detail message
detail = error_details_pb2.DebugInfo()
detail.detail = 'Detailed error information'

# Serialize the message to a string
serialized_detail = detail.SerializeToString()

# Deserialize the string back to a message
new_detail = error_details_pb2.DebugInfo()
new_detail.ParseFromString(serialized_detail)

print(new_detail.detail)