Registry /
web-framework / pyobjc-framework-webkit
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
muslpy 3.10–3.95 runs
build_error
glibcpy 3.10–3.95 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
WebKit
✓ import WebKit
The WebKit framework bindings are accessed directly through the 'WebKit' package.
AppKit
✓ import AppKit
Most practical uses of WebKit will require AppKit for windowing and application management.
Foundation
✓ import Foundation
Foundation framework provides core data types and utilities, often used with WebKit for URLs and requests.
This minimal example demonstrates how to create a basic macOS application window using AppKit and embed a WKWebView to display a webpage. It defines an AppDelegate to manage the application lifecycle and sets up a window with a WKWebView loading a URL. To run this, save it as a .py file and execute it on macOS with PyObjC installed. Note that a full macOS application with an Info.plist and bundle identifier is typically created using tools like `py2app` for deployment, but this script provides a runnable demonstration within a standard Python environment. The URL is conditionally set to avoid issues when run from an unbundled script without a default bundle ID.
import AppKit
import Foundation
import WebKit
class AppDelegate(AppKit.NSObject):
def applicationDidFinishLaunching_(self, notification):
rect = Foundation.NSMakeRect(0, 0, 800, 600)
self.window = AppKit.NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(
rect, AppKit.NSWindowStyleMaskTitled | AppKit.NSWindowStyleMaskClosable | AppKit.NSWindowStyleMaskResizable, AppKit.NSBackingStoreBuffered, False
)
self.window.setTitle_("PyObjC WebKit Demo")
self.webView = WebKit.WKWebView.alloc().initWithFrame_(rect)
self.window.contentView().addSubview_(self.webView)
url = Foundation.NSURL.URLWithString_("https://www.apple.com/" if not Foundation.NSBundle.mainBundle().bundleIdentifier() else "https://www.google.com")
request = Foundation.NSURLRequest.requestWithURL_(url)
self.webView.loadRequest_(request)
self.window.makeKeyAndOrderFront_(None)
def applicationShouldTerminateAfterLastWindowClosed_(self, sender):
return True
if __name__ == "__main__":
app = AppKit.NSApplication.sharedApplication()
delegate = AppDelegate.alloc().init()
app.setDelegate_(delegate)
app.run()
Debug
Known issues
breakingPyObjC v12.0 dropped support for Python 3.9, and v11.0 dropped support for Python 3.8. Ensure your Python environment is 3.10 or newer for PyObjC 12.x.fixUpgrade to Python 3.10 or a newer supported version.
affects: 11.0+
breakingPyObjC v10.3 introduced a change where `__init__` methods in Python subclasses of Objective-C classes would not be called if a user-defined `__new__` was not present. This broke several projects. While partially reverted in v10.3.1 to allow `__init__` when a user *does* implement `__new__`, code relying on PyObjC's auto-generated `__new__` still cannot use `__init__` in the traditional Python sense.fixUpgrade to PyObjC 10.3.1 or newer. If implementing Objective-C style initializers, follow the `alloc().init...()` pattern or implement a custom `__new__` method in your Python class to allow `__init__` to be called.
affects: 10.3 - 10.3.0
gotchaBuilding PyObjC (including framework bindings) from source requires Xcode Command Line Tools to be installed, which provides the necessary compilers and SDKs. Without them, installation via `pip install --no-binary :all: pyobjc-framework-webkit` will fail.fixInstall Xcode Command Line Tools using `xcode-select --install` in your terminal.
affects: All versions (when installing from source)
gotchaConflicting `AppKit` packages can cause `ImportError`. If you encounter 'No module named AppKit' after installing PyObjC, check if another non-PyObjC `AppKit` package is installed.fixUninstall any conflicting `AppKit` packages (e.g., `conda uninstall AppKit` or `pip uninstall AppKit`) and then reinstall PyObjC packages (`pip install --upgrade --force-reinstall pyobjc pyobjc-core`).
affects: All versions
gotchaDue to the underlying Objective-C runtime, it's generally recommended to avoid subclassing `NSString` or `NSMutableString` in Python, as these classes have special handling in PyObjC and direct subclassing can lead to crashes.fixIf you need string-like behavior, wrap `NSString` instances or use Python's built-in string types instead of subclassing directly.
affects: All versions
Upgrade
Version history
12.2.2latest on PyPI · released Aug 11, 2026
Audit
Dependencies
pyobjc-corerequiredThis package provides the core bridge between Python and Objective-C, essential for all PyObjC framework bindings. It is implicitly installed as a dependency.
pyobjc-framework-CocoaoptionalWhile not a direct PyPI dependency, WebKit applications typically rely on AppKit (part of Cocoa) for UI elements like windows and application loops.