{"id":5811,"library":"pyobjc-framework-photos","title":"PyObjC Framework Photos","description":"This library provides Python wrappers for the Photos framework on macOS, allowing Python applications to interact with the user's photo library. It's part of the larger PyObjC project, enabling access to Objective-C frameworks from Python. The current version is 12.1 and follows the PyObjC project's release cadence, often aligning with macOS SDK updates and Python version support.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","photos","objective-c","framework","gui"],"install":[{"cmd":"pip install pyobjc-framework-photos","lang":"bash","label":"Install pyobjc-framework-photos"}],"dependencies":[],"imports":[{"symbol":"Photos","correct":"import Photos"},{"symbol":"objc","correct":"import objc"}],"quickstart":{"code":"import Photos\nimport objc\n\ndef list_some_photo_data():\n    # All Cocoa calls must be made within an autorelease pool\n    pool = objc.autorelease_pool()\n    try:\n        # Check authorization status for Photos access\n        status = Photos.PHPhotoLibrary.authorizationStatus()\n\n        if status == Photos.PHAuthorizationStatusAuthorized:\n            print(\"Photos access is authorized.\")\n            \n            # Fetch all user albums\n            user_albums = Photos.PHAssetCollection.fetchAssetCollectionsWithType_subtype_options_(\n                Photos.PHAssetCollectionTypeAlbum,\n                Photos.PHAssetCollectionSubtypeAny,\n                None\n            )\n            print(f\"Found {user_albums.count()} user albums:\")\n            for i in range(min(3, user_albums.count())): # List up to 3 albums\n                album = user_albums.objectAtIndex_(i)\n                print(f\"- {album.localizedTitle()}\")\n        elif status == Photos.PHAuthorizationStatusLimited:\n            print(\"Photos access is limited (user selected specific photos).\")\n            # Can still fetch, but only for selected photos\n        else:\n            print(f\"Photos access is not authorized. Current status: {status}\")\n            print(\"Please ensure your application (or terminal) has Photos access granted in System Settings > Privacy & Security > Photos.\")\n    finally:\n        # The pool must be released\n        del pool\n\nif __name__ == '__main__':\n    list_some_photo_data()","lang":"python","description":"This quickstart demonstrates how to check Photos library authorization and list the titles of a few user-created albums. This code must be run on macOS. You might need to grant your Python environment (e.g., Terminal.app or your IDE) access to Photos via System Settings > Privacy & Security > Photos."},"warnings":[{"fix":"Ensure your Python environment is 3.10 or newer. Upgrade Python if necessary.","message":"PyObjC 12.0 dropped support for Python 3.9. PyObjC 11.0 dropped support for Python 3.8. The latest versions require Python 3.10 or later.","severity":"breaking","affected_versions":"12.0+"},{"fix":"Only use this library on macOS systems. Cross-platform applications requiring photo access will need alternative solutions for non-macOS platforms.","message":"PyObjC (and thus `pyobjc-framework-photos`) is a macOS-specific library. It provides bindings to Apple's Objective-C frameworks, which are only available on macOS.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review custom Python `init` methods for Objective-C classes, especially regarding ownership and reference counts. Test your application thoroughly after upgrading to 11.1 or later if you have such methods.","message":"PyObjC 11.1 introduced significant changes to how initializer methods are modeled, aligning with `clang`'s automatic reference counting (ARC) documentation. Custom `init` methods in Python subclasses might behave differently regarding reference counting.","severity":"breaking","affected_versions":"11.1+"},{"fix":"If using Python 3.13 with PyObjC, be aware that free-threading support is experimental. Monitor PyObjC release notes for updates on stability. For critical applications, consider using Python 3.12 or earlier until free-threading support is mature.","message":"Experimental free-threading support (PEP 703) in Python 3.13 is *not* fully supported by PyObjC. While PyObjC 11.0 introduced *experimental* support, there may still be stability or performance issues when running with free-threading enabled.","severity":"gotcha","affected_versions":"11.0+"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}