Question Details

No question body available.

Tags

python windows

Answers (1)

February 13, 2026 Score: 4 Rep: 1,487 Quality: Medium Completeness: 80%

You’re mixing two different Pythons / runtimes.

pacman -S mingw-w64-ucrt-x8664-python-gobject installs PyGObject for the MSYS2 UCRT64 Python (/ucrt64/bin/python).
But pip install pygobject you ran in cmd almost certainly went into your Windows Python (or a different Python), and that one can’t find the MSYS2 DLLs →
gi fails to load.

Use MSYS2’s Python only

  • Open “MSYS2 UCRT64” shell (not cmd)

  • Verify you’re using the right python:

    • which python -> should be /ucrt64/bin/python

    • python -c "import sys; print(sys.executable)"

  • Install everything via pacman (don’t pip pygobject):

    • pacman -S mingw-w64-ucrt-x8664-python-gobject mingw-w64-ucrt-x8664-gtk3 mingw-w64-ucrt-x8664-python-cairo mingw-w64-ucrt-x8664-gobject-introspection

If you want to run from cmd/PowerShell, run the MSYS2 python explicitly:

  • C:\msys64\ucrt64\bin\python.exe your_script.py
    (and make sure C:\msys64\ucrt64\bin is on PATH, or just use the full path above)

If you insist on Windows Python + pip
On Windows, pip install pygobject is often painful because it needs native deps (GTK, gobject-introspection, libffi) and compatible wheels aren’t always available. Easiest alternatives are:

  • use MSYS2 (path 1), or

  • use conda/mamba environments that bundle GTK/PyGObject.