Install & Compatibility
Where this runs
tested against v5.1.2 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.512s · 24.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.1s · import 0.452s · 25MB
23MB installed
● package 23MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Configuration
✓ import mux_python
configuration = mux_python.Configuration()
Configuration object is directly within the top-level `mux_python` module.
ApiClient
✓ client = mux_python.ApiClient(configuration)
ApiClient is instantiated from the top-level `mux_python` module.
ApiException
✓ from mux_python.rest import ApiException
Common exceptions like `ApiException` are found in the `mux_python.rest` submodule.
AssetsApi
✓ assets_api = mux_python.AssetsApi(client)
API client classes like `AssetsApi` are available directly from the top-level `mux_python` module and require an `ApiClient` instance.
This quickstart demonstrates how to initialize the Mux Python client using API credentials from environment variables and then list all existing video assets in your Mux account. Mux API responses typically return the primary data object within a `.data` attribute.
import os
import mux_python
from mux_python.rest import ApiException
# Authentication Setup
configuration = mux_python.Configuration()
configuration.username = os.environ.get('MUX_TOKEN_ID', '')
configuration.password = os.environ.get('MUX_TOKEN_SECRET', '')
if not configuration.username or not configuration.password:
print("Error: MUX_TOKEN_ID and MUX_TOKEN_SECRET environment variables must be set.")
exit(1)
# API Client Initialization
api_client = mux_python.ApiClient(configuration)
assets_api = mux_python.AssetsApi(api_client)
try:
# List Assets
print("Listing Mux Assets:")
list_assets_response = assets_api.list_assets()
if list_assets_response.data:
for asset in list_assets_response.data:
print(f" Asset ID: {asset.id}, Status: {asset.status}, Duration: {asset.duration}")
else:
print(" No assets found.")
except ApiException as e:
print(f"Exception when calling AssetsApi->list_assets: {e}\n")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Errors
Common errors & fixes
mux_python.rest.ApiException: (401)
Reason: Unauthorized
The Mux API token ID or secret key provided are incorrect or invalid for the requested operation. This often manifests as a `mux_python.rest.ApiException` with an HTTP status code of 401.
fixEnsure that `configuration.username` (Mux Token ID) and `configuration.password` (Mux Token Secret) are set correctly, typically via environment variables (`os.environ['MUX_TOKEN_ID']` and `os.environ['MUX_TOKEN_SECRET']`).
ModuleNotFoundError: No module named 'mux_python'
The `mux-python` library is not installed in the current Python environment, or the environment where the script is being run does not have access to the installed library.
fixInstall the library using pip: `pip install mux-python` or `pip3 install mux-python` if you have multiple Python versions.
AttributeError: 'ResponseObject' object has no attribute 'expected_attribute'
You are trying to access an attribute or method on a `mux-python` object (e.g., an API response) that does not exist or has a different name than expected. Often, the core data in Mux API responses is nested under a `.data` attribute.
fixConsult the `mux-python` documentation for the specific API response object to identify the correct attribute names. Frequently, the desired data will be found within the `.data` attribute of the response object (e.g., `response_object.data.id` instead of `response_object.id`).
KeyError: 'some_key'
Attempting to access a non-existent key in a dictionary-like object returned by `mux-python` (e.g., when processing API response data or retrieving environment variables for configuration).
fixVerify that the key exists before attempting to access it. Use `dictionary.get('some_key', default_value)` to provide a default value if the key is missing, or check for key existence with `if 'some_key' in dictionary:` before direct access. Ensure all required environment variables, like `MUX_TOKEN_ID` and `MUX_TOKEN_SECRET`, are properly set. Upgrade
Version history
5.1.2latest on PyPI · released Jan 8, 2026
Audit
Dependencies
No dependency data recorded yet.