Registry / type-stubs / pyobjc-framework-medialibrary

pyobjc-framework-medialibrary

JSON →
library12.2pypypiunverified

pyobjc-framework-medialibrary provides Python wrappers for the macOS MediaLibrary framework, which allows access to media content managed by applications like Photos, Music, and TV. It is part of the larger PyObjC project, a bridge that enables Python scripts to interact with Objective-C class libraries, most notably Apple's Cocoa frameworks. The current version is 12.1, and the project maintains an active release cadence, frequently updating bindings for new macOS SDKs.

pip install pyobjc-framework-medialibrary
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-M
P
pyobjc-framework-medialibrary
type-stubspythonv12.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
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.940 runs
build_error
glibc
py 3.103.940 runs
build_error
Code
Verified usage

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

MLMediaLibrary
from MediaLibrary import MLMediaLibrary
PyObjC maps macOS frameworks to Python packages with the same name. Classes within the framework are available directly from the imported package.

This quickstart demonstrates how to import and instantiate the `MLMediaLibrary` class to access macOS media sources. Due to restrictions of the underlying macOS framework, this code may encounter runtime errors (e.g., 'XPC connection interrupted') if not executed within a properly signed macOS application bundle or without appropriate entitlements.

import MediaLibrary # Create an instance of MLMediaLibrary # WARNING: MLMediaLibrary often requires running within a macOS application bundle # or with specific entitlements to avoid 'XPC connection interrupted' errors # in command-line contexts. This example may not function fully outside an app. try: media_library = MediaLibrary.MLMediaLibrary.alloc().initWithOptions_(None) if media_library: print(f"Successfully instantiated MLMediaLibrary: {media_library}") # Attempt to get media sources - this might fail if not in an app context media_sources = media_library.mediaSources() if media_sources: print(f"Found {len(media_sources)} media sources.") for source in media_sources: # Accessing properties like mediaSourceIdentifier() might require an active app context. try: identifier = source.mediaSourceIdentifier() print(f"- Source Identifier: {identifier}") except Exception as prop_e: print(f"- Could not get source identifier for a media source: {prop_e}") else: print("No media sources found or could not access them.") else: print("Failed to instantiate MLMediaLibrary (returned None).") except Exception as e: print(f"An error occurred during MLMediaLibrary instantiation or access: {e}") print("This often indicates issues with entitlements or running outside an app bundle.")
Debug
Known issues
breakingPyObjC 12.0 dropped support for Python 3.9. Projects using older Python versions must upgrade to Python 3.10 or later to use `pyobjc-framework-medialibrary` 12.x. PyObjC 11.0 dropped Python 3.8 support.
fix
Ensure your Python environment is 3.10 or newer. Consider using Python 3.11 or later for the best compatibility and features.
affects: >=12.0 (Python 3.9), >=11.0 (Python 3.8)
breakingPyObjC 11.1 introduced significant changes to how initializer methods (methods in the 'init' family) handle Automatic Reference Counting (ARC), aligning with `clang`'s documentation. This means such methods now correctly 'steal' a reference to `self` and return a new one, which might alter reference counting behavior in complex Objective-C/Python interactions.
fix
Review custom Objective-C classes exposed to Python via PyObjC, especially those with custom `init` methods, to ensure correct memory management under the new ARC behavior.
affects: >=11.1
gotchaUsing `MLMediaLibrary` (and many other macOS frameworks) from a plain Python script executed from the command line can lead to `XPC connection interrupted` errors. These frameworks often expect to be run within a full macOS application bundle with specific entitlements.
fix
For production or robust usage, consider building your Python script into a macOS application bundle using `py2app` and ensuring proper entitlements are configured. For development, be aware that functionality may be limited or unreliable outside an app context.
affects: All
gotchaPyObjC 10.3 initially removed the ability to call `__init__` on Objective-C classes when a Python class (or its superclass) defines `__new__`. While 10.3.1 partially reintroduced this for user-implemented `__new__`, it remains a nuanced interaction where standard Python object initialization patterns might clash with PyObjC's object lifecycle.
fix
When subclassing Objective-C classes in Python and overriding `__new__`, be cautious about how `__init__` is used. Prefer `alloc().init*()` patterns directly, or ensure your `__new__` and `__init__` adhere to PyObjC's expectations for Objective-C object construction.
affects: >=10.3
gotchaPyObjC 11.0 introduced *experimental* support for free-threading (PEP 703) in Python 3.13. While this is an exciting development, experimental features may have stability issues or unexpected behavior. Note that earlier versions (e.g., 10.3) explicitly stated lack of support for Python 3.13's free threading.
fix
If working with Python 3.13 and PyObjC in a free-threaded environment, be prepared for potential stability issues. It is recommended to thoroughly test your application and refer to PyObjC's latest documentation regarding free-threading compatibility.
affects: >=11.0 with Python 3.13+
Upgrade
Version history
12.2latest on PyPI · released May 30, 2026
Audit
Dependencies
pyobjc-corerequiredThis package is a wrapper for a macOS framework and relies on the core PyObjC bridge functionality.
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
2
Resources
pyobjc-framework-medialibrary — pip install pyobjc-framework-medialibrary · libregistry