Registry / web-framework / pygobject

pygobject

JSON →
library3.58.0pypypiunverified

PyGObject is a Python package providing bindings for GObject-based libraries, including GTK, GStreamer, WebKitGTK, GLib, and GIO. It allows Python applications to interact with the entire GNOME software platform through GObject Introspection. The current version is 3.56.2 and it supports Linux, Windows, macOS, and Python 3.10+.

pip install PyGObject
INSTALL
IMPORT
SIG · PYGOBJECT
P
pygobject
web-frameworkpythonv3.58.0
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.95 runs
build_error
glibc
py 3.103.95 runs
build_error
Code
Verified usage

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

gi
import gi
import gtk # or import glib
Old static bindings (e.g., 'import gtk' for GTK2) are deprecated and no longer supported in modern PyGObject versions, which use GObject Introspection via 'gi.repository'.
Gtk
from gi.repository import Gtk
Accessed through the 'gi.repository' namespace after calling 'gi.require_version()'.
require_version
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk # directly
It is crucial to call gi.require_version() before importing from gi.repository to specify the desired version of a library (e.g., GTK 4.0), preventing conflicts or unexpected behavior if multiple versions are installed on the system.

This 'Hello World' example demonstrates a basic GTK4 application using PyGObject. It initializes the GTK4 library, creates a Gtk.Application, and displays a window with 'Hello World' as its title.

import gi gi.require_version('Gtk', '4.0') from gi.repository import GLib, Gtk class MyApplication(Gtk.Application): def __init__(self): super().__init__(application_id="com.example.MyGtkApplication") GLib.set_application_name('My Gtk Application') def do_activate(self): window = Gtk.ApplicationWindow(application=self, title="Hello World") window.present() app = MyApplication() app.run()
Debug
Known issues
breakingThe `pygtkcompat` module, used for porting legacy GTK2/Python2 code, was deprecated in PyGObject 3.48 and entirely removed in 3.52.0. Code relying on this compatibility layer will break.
fix
Migrate code fully to modern PyGObject and GTK3+ APIs. Refer to PyGObject's 'Porting from Static Bindings' documentation.
affects: >=3.52.0
breakingPyGObject 3.55.0 removed 'toggle references'. If you used Python weakrefs to track PyGObjects, you must change them to `GObject.Object.weak_ref()`.
fix
Replace Python weakrefs with `GObject.Object.weak_ref()` for tracking GObjects.
affects: >=3.55.0
gotchaInstalling PyGObject via pip often requires system-level development packages (e.g., GTK development files, gobject-introspection, a C compiler) which are not installed by `pip`. The `pip install` command is primarily for the Python bindings, not the underlying GObject/GTK libraries.
fix
Follow platform-specific installation instructions for system dependencies (e.g., `sudo apt install python3-gi gir1.2-gtk-4.0` on Debian/Ubuntu, MSYS2 for Windows) before `pip install PyGObject`.
affects: All versions
gotchaWhen importing `Gdk` or `Gtk`, their `init_check()` functions are automatically called for backwards compatibility. This prevents calling `Gtk.disable_setlocale()` as it must be called before GTK initialization.
fix
To skip auto-initialization, call `gi.disable_legacy_autoinit()` before importing `Gdk` or `Gtk`.
affects: All versions
deprecatedCalling GLib API through the GObject namespace (e.g., `GObject.some_glib_function()`) was deprecated in PyGObject 3.7.2. This usage will likely be removed in future versions.
fix
Call GLib API directly through the `GLib` namespace (e.g., `GLib.some_function()`) after importing `GLib` from `gi.repository`.
affects: >=3.7.2
Upgrade
Version history
3.58.0latest on PyPI · released Aug 28, 2026
Audit
Dependencies
pycairooptionalCommonly used for drawing operations within GTK applications, often installed alongside PyGObject.
Agent activity
8 hits · last 30 days
node
6
Resources
pygobject — pip install pygobject · libregistry