Google API Core

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

Google API Core is a foundational library for Python clients of Google APIs, providing essential features like authentication, request handling, and response parsing. The current version is 2.30.0, released on February 17, 2026. The library maintains a regular release cadence, ensuring compatibility and feature enhancements.

pip install google-api-core
error ModuleNotFoundError: No module named 'google.api_core'
cause This error occurs when the `google-api-core` library, or one of its dependencies, is not installed in the Python environment, or there's an issue with the Python path preventing the interpreter from finding the module.
fix
Ensure google-api-core and its associated Google Cloud client libraries are correctly installed. It often helps to upgrade related packages as well.
pip install --upgrade google-api-core google-cloud-core google-api-python-client
error AttributeError: module 'google.api_core' has no attribute 'gapic_v1'
cause This error typically arises from a version conflict where an older version of `google-api-core` is being used with a newer Google Cloud client library that expects the `gapic_v1` module or structure, which was introduced or changed in later versions of `google-api-core`.
fix
Upgrade the google-api-core library to a compatible version with your Google Cloud client libraries. Pinning the version of google-api-core or the specific client library might be necessary to avoid future conflicts.
pip install --upgrade google-api-core
# If a specific version is required:
pip install google-api-core==<compatible_version>
error google.api_core.exceptions.PermissionDenied: 403 Request had insufficient authentication scopes
cause This exception indicates that the authenticated principal (service account or user) attempting to make the API call lacks the necessary IAM permissions or the required OAuth scopes to access the requested resource or perform the operation.
fix
Verify that the service account or user credentials have the correct IAM roles assigned for the resource they are trying to access, and that the Python script explicitly requests the necessary OAuth scopes during authentication.
from google.cloud import storage
# Example with explicit scopes for a client (if using service account JSON)
# Or ensure your service account has roles like 'Storage Object Viewer' or 'Storage Object Admin'
client = storage.Client()
# ... your code ...
error google.api_core.exceptions.ServiceUnavailable: 503 failed to connect to all addresses
cause This error signifies a connectivity problem where the client cannot establish a connection to the Google API endpoint. This can be caused by network issues, firewall restrictions, incorrect DNS resolution, or the target service being temporarily unavailable.
fix
Check your network connectivity, firewall rules, and DNS settings to ensure that outbound connections to Google API endpoints (e.g., googleapis.com on port 443) are allowed. Temporarily reducing the number of concurrent requests or retrying with exponential backoff can also help if the issue is intermittent service unavailability.
gotcha Python 3.9 is no longer actively supported for future updates by google-api-core. While it might still function, it is recommended to upgrade to Python 3.10 or higher for continued support and updates.
fix Upgrade your Python environment to Python 3.10 or higher.
breaking The minimum required version of protobuf has been updated to 4.25.8.
fix Ensure that protobuf version 4.25.8 or higher is installed.
gotcha Direct imports from submodules like google.api_core.exceptions may lead to ImportError.
fix Use the correct import statement: from google.api_core import exceptions.
gotcha Using deprecated methods may lead to unexpected behavior.
fix Refer to the latest documentation to identify and replace deprecated methods.
gotcha Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, potentially rendering your system unusable.
fix It is recommended to use a virtual environment or use the --root-user-action option if you understand the risks and want to suppress this warning.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.29s 46.1M
3.10 slim (glibc) - - 0.15s 47M
3.11 alpine (musl) - - 0.69s 49.9M
3.11 slim (glibc) - - 0.21s 51M
3.12 alpine (musl) - - 0.60s 41.4M
3.12 slim (glibc) - - 0.26s 42M
3.13 alpine (musl) - - 0.80s 41.1M
3.13 slim (glibc) - - 0.29s 42M
3.9 alpine (musl) - - 0.20s 46.1M
3.9 slim (glibc) - - 0.14s 47M

Basic usage of google-api-core to handle exceptions when interacting with Google APIs.

from google.api_core import exceptions

try:
    # Your code that interacts with Google APIs
    pass
except exceptions.GoogleAPICallError as e:
    print(f"An error occurred: {e}")