Registry / gcp / google-cloud-artifact-registry

google-cloud-artifact-registry

JSON →
library1.22.0pypypi✓ verified 23d ago

The `google-cloud-artifact-registry` client library for Python allows developers to interact with Google Cloud Artifact Registry. This service provides a universal package manager for various artifact formats, including Docker images, Maven artifacts, npm packages, and more. The library is currently at version 1.21.0 and is part of the actively maintained Google Cloud Python client libraries, receiving frequent updates.

pip install google-cloud-artifact-registry
INSTALL
IMPORT
SIG · GOOGLE-CLOUD-ARTIF
G
google-cloud-artifact-registry
gcppythonv1.22.0
Install
5.8s avg
Import
1667ms
Disk
71MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.22.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.95 runs
installs and imports cleanly · install 0.0s · import 1.994s · 72.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.8s · import 1.340s · 71MB
71MB installed
● package 71MB
Code
Verified usage

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

ArtifactRegistryClient
from google.cloud.artifactregistry_v1 import ArtifactRegistryClient
ArtifactRegistryAsyncClient
from google.cloud.artifactregistry_v1 import ArtifactRegistryAsyncClient
Use the async client for non-blocking I/O operations.

This quickstart demonstrates how to initialize the `ArtifactRegistryClient` and list repositories within a specified Google Cloud project and location. It highlights the use of `parent` resource names and iterating over paginated results.

import os from google.cloud.artifactregistry_v1 import ArtifactRegistryClient def list_repositories(project_id: str, location: str): """Lists repositories in a given project and location.""" client = ArtifactRegistryClient() # The parent resource name for the project and location parent = f"projects/{project_id}/locations/{location}" try: print(f"Listing repositories in {parent}...") # list_repositories returns an iterator, common for Google Cloud APIs repositories = client.list_repositories(parent=parent) found = False for repo in repositories: print(f"- {repo.name} (Format: {repo.format.name}, Description: {repo.description})") found = True if not found: print("No repositories found.") except Exception as e: print(f"Error listing repositories: {e}") if __name__ == "__main__": # Set these environment variables or replace the placeholders PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "your-gcp-project-id") LOCATION = os.environ.get("GCP_LOCATION", "us-central1") # e.g., 'us-central1', 'europe-west1' if PROJECT_ID == "your-gcp-project-id": print("Please set the GCP_PROJECT_ID environment variable or replace 'your-gcp-project-id'.") print("Also ensure you are authenticated (e.g., `gcloud auth application-default login`).") else: list_repositories(PROJECT_ID, LOCATION)
Debug
Known issues
gotchaArtifact Registry resources (repositories, packages, artifacts) are regional. Operations like listing or creating repositories must specify a valid `location` (e.g., 'us-central1', 'europe-west1'). Forgetting this or using an incorrect region will result in 'NotFound' or 'PermissionDenied' errors, even if the resource exists in another region.
fix
Always specify the correct `location` parameter in your API calls, typically in the `parent` resource name string (e.g., `projects/{project_id}/locations/{location}`).
affects: >=1.0.0
gotchaMany Artifact Registry API calls require fully qualified resource names (e.g., `projects/PROJECT_ID/locations/LOCATION/repositories/REPOSITORY_ID`). Incorrectly formatting these strings is a common source of `INVALID_ARGUMENT` or `NotFound` errors.
fix
Ensure that resource name strings are constructed precisely according to the API documentation. For instance, `client.repository_path(project, location, repository_id)` can be used to generate the correct format.
affects: >=1.0.0
gotchaThe client library uses Application Default Credentials for authentication. If your code is running outside of Google Cloud (e.g., on a local machine), you must explicitly authenticate (e.g., via `gcloud auth application-default login`) or set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. Incorrect setup often leads to `google.auth.exceptions.DefaultCredentialsError` or `PermissionDenied` errors.
fix
Verify that the environment has access to valid credentials and that the principal (user or service account) has the necessary IAM roles (e.g., 'Artifact Registry Reader' or 'Artifact Registry Administrator') for the resources it's attempting to access.
affects: >=1.0.0
Errors
Common errors & fixes
403 Forbidden
This error typically indicates that the authenticated user or service account lacks the necessary IAM permissions to perform the requested operation (e.g., push, pull, list) on the Artifact Registry repository, or the authentication configuration (e.g., Docker credentials) is incorrect or expired.
fix
Ensure the service account or user has the appropriate IAM roles (e.g., `Artifact Registry Reader` for pulling, `Artifact Registry Writer` for pushing) on the target repository. For Docker, run `gcloud auth configure-docker <REGION>-docker.pkg.dev` to refresh credentials. For Python packages, ensure `keyrings.google-artifactregistry-auth` is installed and configured, or pass credentials via `gcloud artifacts print-settings python`.
ModuleNotFoundError: No module named 'google.cloud.artifactregistry'
The `google-cloud-artifact-registry` Python client library has not been installed in the Python environment where the code is being executed.
fix
Install the library using pip: `pip install google-cloud-artifact-registry`. Ensure you are installing it in the correct virtual environment if you are using one.
Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
This error occurs when the Docker client cannot establish a connection with the Docker daemon, which is a prerequisite for pushing or pulling Docker images to/from Artifact Registry.
fix
Start the Docker daemon on your local machine. If connecting to a remote daemon, verify that `DOCKER_HOST` is correctly configured and the remote daemon is running and accessible.
HTTP Error 404 - Not Found
When interacting with Python packages via `pip` or `twine`, this error indicates that the requested package or a specific version of it could not be found in the specified Artifact Registry repository, or the repository URL is incorrect.
fix
Double-check the package name, version, and the full repository URL used in your `pip` or `twine` command. Verify the package exists in the repository by listing its contents in the Google Cloud Console or using `gcloud artifacts packages list`.
Upgrade
Version history
1.22.0latest on PyPI · released Jun 3, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
36 hits · last 30 days
node
32
Amazon
1
OpenAI (training)
1
Resources
google-cloud-artifact-registry — pip install google-cloud-artifact-registry · libregistry