{"id":6190,"library":"pyobjc-framework-virtualization","title":"PyObjC Virtualization Framework","description":"pyobjc-framework-virtualization provides Python wrappers for Apple's Virtualization framework on macOS. It is part of the PyObjC project, a bidirectional bridge enabling Python scripts to interact with Objective-C libraries, including macOS Cocoa frameworks. The current version is 12.1, and it maintains an active release cadence, typically 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","virtualization","objc","pyobjc","framework"],"install":[{"cmd":"pip install pyobjc-framework-virtualization","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core bridge for Python and Objective-C communication.","package":"pyobjc-core","optional":false},{"reason":"Provides fundamental macOS UI and app infrastructure classes, often implicitly used or required by other frameworks.","package":"pyobjc-framework-Cocoa","optional":false}],"imports":[{"note":"The entire framework's bindings are typically imported as a top-level module named after the framework itself.","symbol":"Virtualization","correct":"import Virtualization"},{"note":"Specific classes are accessed directly from the imported framework module.","symbol":"VZVirtualMachine","correct":"from Virtualization import VZVirtualMachine"}],"quickstart":{"code":"import Virtualization\nimport os\n\ndef check_virtualization_support():\n    print(f\"Checking macOS Virtualization support...\")\n    if Virtualization.VZVirtualMachine.isSupported():\n        print(\"\\u2705 macOS Virtualization framework is supported on this machine.\")\n        print(\"    You can now proceed to create VZVirtualMachineConfiguration objects and manage virtual machines.\")\n        # Further steps would involve creating a VZVirtualMachineConfiguration,\n        # setting up devices, and booting a guest OS, which is beyond a quickstart.\n        # Example of a next step (not fully runnable without more config):\n        # config = Virtualization.VZVirtualizationMachineConfiguration.alloc().init()\n        # if config.validateWithError_(None):\n        #     print(\"    Basic VZVirtualMachineConfiguration object could be initialized.\")\n    else:\n        print(\"\\u274C macOS Virtualization framework is NOT supported on this machine.\")\n        print(\"    Requires macOS 11 or later and Apple Silicon or Intel with VT-x.\")\n\nif __name__ == \"__main__\":\n    check_virtualization_support()","lang":"python","description":"This quickstart checks if the macOS Virtualization framework is supported on the current machine. This is the simplest interaction with the framework without requiring complex setup or specific entitlements. Actual virtual machine creation and execution involve more extensive configuration and may require specific macOS entitlements."},"warnings":[{"fix":"Upgrade your Python environment to Python 3.10 or later for PyObjC 12.x. Always check `requires_python` on PyPI or the PyObjC changelog for specific version requirements.","message":"PyObjC frequently drops support for older Python versions. PyObjC 12.0 dropped support for Python 3.9, and PyObjC 11.0 dropped Python 3.8. Ensure your Python version is compatible with the PyObjC version you are installing.","severity":"breaking","affected_versions":"11.0, 12.0"},{"fix":"Review code that interacts with object initialization, especially custom subclasses or factory methods, to ensure correct reference handling. Explicit memory management is rarely needed in Python, but understanding the underlying Objective-C semantics is crucial for correct behavior.","message":"PyObjC 11.1 changed how Objective-C initializer methods (those in the `init` family) are modeled, now correctly reflecting that they 'steal' a reference to `self` and return a new one, as per clang's Automatic Reference Counting (ARC) documentation. This affects object lifecycle and reference counting.","severity":"breaking","affected_versions":">=11.1"},{"fix":"Ensure your macOS application (or a development sandbox configuration) includes the `com.apple.security.virtualization` entitlement to fully utilize the Virtualization framework. This is usually configured in Xcode for native applications.","message":"Actual creation and running of `VZVirtualMachine` instances typically requires your application to have the `com.apple.security.virtualization` entitlement. Without this, operations like `start()` may fail with permission errors.","severity":"gotcha","affected_versions":"All"},{"fix":"If encountering issues with custom `__new__` and `__init__` behavior, upgrade to PyObjC 10.3.1 or later.","message":"PyObjC 10.3 temporarily removed support for calling `__init__` on Python classes that also define a user-implemented `__new__` method, causing breakage in some projects. This was reverted in version 10.3.1. [from prompt]","severity":"gotcha","affected_versions":"10.3"},{"fix":"Ensure your development and deployment environment is macOS to use this library.","message":"PyObjC is a wrapper for macOS-specific frameworks. Therefore, `pyobjc-framework-virtualization` is only functional on macOS and is not intended for cross-platform use.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}