Registry / gcp / google-api-core

google-api-core

JSON →
library2.30.0pypypi✓ verified 52d ago

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.

gcphttp-networkingauth-securityserialization
pip install google-api-core
Install & Compatibility
Where this runs
tested against v2.31.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.925 runs
installs and imports cleanly · install 0.0s · import 0.468s · 47.2MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 4.1s · import 0.194s · 48MB
46MB installed
● package 46MB
Code
Verified usage

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

google.api_core.exceptions
from google.api_core import exceptions
import google.api_core.exceptions
Direct import may lead to ImportError; use the correct import statement.
google.api_core.retry
from google.api_core import retry
import google.api_core.retry
Direct import may lead to ImportError; use the correct import statement.

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}")
Debug
Known issues
gotchaPython 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.
affects: 2.30.0 and above
breakingThe minimum required version of protobuf has been updated to 4.25.8.
fix
Ensure that protobuf version 4.25.8 or higher is installed.
affects: 2.30.0 and above
gotchaDirect imports from submodules like google.api_core.exceptions may lead to ImportError.
fix
Use the correct import statement: from google.api_core import exceptions.
affects: All versions
gotchaUsing deprecated methods may lead to unexpected behavior.
fix
Refer to the latest documentation to identify and replace deprecated methods.
affects: All versions
gotchaRunning 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.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'google.api_core'
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.

```bash
pip install --upgrade google-api-core google-cloud-core google-api-python-client
```
AttributeError: module 'google.api_core' has no attribute 'gapic_v1'
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.

```bash
pip install --upgrade google-api-core
# If a specific version is required:
pip install google-api-core==<compatible_version>
```
google.api_core.exceptions.PermissionDenied: 403 Request had insufficient authentication scopes
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.

```python
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 ...
```
google.api_core.exceptions.ServiceUnavailable: 503 failed to connect to all addresses
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.
Upgrade
Version history
2.31.0latest on PyPI
Audit
Dependencies
protobufrequiredRequired for protocol buffer support
grpciooptionalRequired for gRPC support
Agent activity
64 hits · last 30 days
node
16
seranking-bot
3
ahrefsbot
2
bytedance
1
googlebot
1
Resources