Registry / aws / python-glanceclient

python-glanceclient

JSON →
library4.12.0pypypi✓ verified 87d ago

python-glanceclient is a client library for OpenStack Glance, the Image service, built on the Glance API. It provides a Python API for interacting with Glance and a command-line tool (`glance`). The current stable version is 4.11.0, and it follows the OpenStack release cadence, typically releasing new versions every six months to align with OpenStack's development cycle.

pip install python-glanceclient
INSTALL
IMPORT
SIG · PYTHON-GLANCECLIEN
P
python-glanceclient
awspythonv4.12.0
Install
6.5s avg
Import
681ms
Disk
75MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.12.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.920 runs
installs and imports cleanly · install 0.0s · import 0.695s · 72.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 6.5s · import 0.667s · 73MB
75MB installed
● package 75MB
Code
Verified usage

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

Client
from glanceclient import client as glance_client
from glanceclient.v2 import client
While specific API versions existed in direct imports in older libraries, the recommended pattern for `python-glanceclient` is to import the generic `client` module and instantiate `glance_client.Client('2', ...)`.

This quickstart demonstrates how to authenticate with OpenStack Keystone using environment variables and then initialize the Glance client to list available images. It uses API version 2, which is the default for recent Glance client versions. Make sure your OpenStack environment variables (e.g., `OS_AUTH_URL`, `OS_USERNAME`, `OS_PASSWORD`, `OS_PROJECT_NAME`) are set.

import os from keystoneauth1.identity import v3 from keystoneauth1 import session from glanceclient import client as glance_client # --- Authentication --- # Ensure OpenStack environment variables are set (e.g., OS_AUTH_URL, OS_USERNAME, OS_PASSWORD, etc.) # You can also pass credentials directly, but environment variables are recommended. auth = v3.Password( auth_url=os.environ.get('OS_AUTH_URL', 'http://localhost:5000/v3'), username=os.environ.get('OS_USERNAME', 'admin'), password=os.environ.get('OS_PASSWORD', 'password'), project_name=os.environ.get('OS_PROJECT_NAME', 'admin'), user_domain_name=os.environ.get('OS_USER_DOMAIN_NAME', 'Default'), project_domain_name=os.environ.get('OS_PROJECT_DOMAIN_NAME', 'Default') ) sess = session.Session(auth=auth) # --- Initialize Glance Client (API v2 recommended) --- glance = glance_client.Client('2', session=sess) # --- List Images --- try: print("\nAvailable Glance Images:") images = glance.images.list() if images: for image in images: print(f" ID: {image.id}, Name: {image.name}, Status: {image.status}, Visibility: {getattr(image, 'visibility', 'unknown')}") else: print(" No images found.") except Exception as e: print(f"Error connecting to Glance or listing images: {e}")
glance --version
Debug
Known issues
breakingThe `glanceclient.client.Client()` constructor defaults to Glance API version 2 (v2) since `python-glanceclient` version 2.0.0. Older applications that implicitly relied on v1 might break or misbehave.
fix
Explicitly pass the desired API version as the first argument, e.g., `glance_client.Client('1', session=sess)` for v1, or `glance_client.Client('2', session=sess)` for v2. It's recommended to upgrade to v2 where possible.
affects: >=2.0.0
gotchaWhile `python-glanceclient` is actively maintained, for new OpenStack-related development, consider using the higher-level `openstacksdk` library. It provides a more unified and consistent API across various OpenStack services.
fix
Explore `openstacksdk`'s documentation for its Glance module. For existing `glanceclient` code, continue using this library, as it remains a valid and supported option.
affects: All
gotchaDirect authentication by passing username/password arguments to client constructors is discouraged for production environments due to security and flexibility concerns. The recommended approach is to use `keystoneauth1` sessions.
fix
Always construct a `keystoneauth1.session.Session` object with an appropriate `keystoneauth1.identity` plugin (e.g., `v3.Password`, `v3.Token`) and pass this session to the `glanceclient.client.Client()` constructor via the `session` keyword argument.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'glanceclient'
The 'python-glanceclient' library is not installed in the current Python environment.
fix
Install the library using pip: `pip install python-glanceclient`
glance: command not found
The 'glance' command-line tool's executable is not in the system's PATH environment variable, or the package was not installed in a way that makes the script accessible.
fix
Ensure 'python-glanceclient' is installed in your active Python environment and that your system's PATH includes the directory where pip installs scripts (e.g., `~/.local/bin` or your virtual environment's `bin` folder).
ERROR: Unauthorized (HTTP 401)
The OpenStack credentials (e.g., OS_AUTH_URL, OS_USERNAME, OS_PASSWORD, OS_PROJECT_NAME) provided are incorrect, missing, or have expired, preventing successful authentication with the Keystone identity service.
fix
Verify and set the correct OpenStack environment variables, or pass the correct authentication parameters when initializing the client. For CLI, source your `openrc` file.
BadRequest: Missing required attribute 'name'
When creating an image via the Python API, a mandatory attribute, such as 'name', was not provided in the arguments to the `images.create()` method.
fix
Ensure all required attributes are included in the dictionary passed to the `glance_client.images.create()` method. For example: `glance_client.images.create(name='my-image', disk_format='qcow2', container_format='bare')`
Upgrade
Version history
4.12.0latest on PyPI · released May 19, 2026
Audit
Dependencies
keystoneauth1requiredRequired for robust authentication against OpenStack Identity (Keystone) service.
openstacksdkrequiredUsed for some common utilities and provides a higher-level abstraction for OpenStack services, including Glance.
Agent activity
9 hits · last 30 days
node
8
Resources
python-glanceclient — pip install python-glanceclient · libregistry