-
Download
precompiled-sdk.zip
, extractbin
directory and set it toPATH
environment variables. -
Copy
pygobject-pycairo-deps\include
,pygobject-pycairo-deps\lib
to yourPython
environment directory. For example, in miniconda python environment, theinclude
path is{CONDA_PATH}\envs\{ENV_NAME}\include
, andlib
path is{CONDA_PATH}\envs\{ENV_NAME}\libs
-
Config
GI_TYPELIB_PATH
environment variable.set GI_TYPELIB_PATH={YOURPATH}\lib\girepository-1.0
-
Force reinstall
pycairo
pip install --force-reinstall -no-binary :all: pycairo
-
Now you can run your scripts.
Or you can use python wheel to install prebuilt GTK libraries. Only support Py3.7 ~ Py3.10.
pip install --no-binary --force-reinstall :all: pygobject-pycairo-prebuilt-libraries-vs2019
How this pygobject-pycairo-prebuilt-libraries-vs2019
package work?
There're prebuilt pygobject, pycairo packages in it, when you setup this package, it will install the pygobject.whl, pycairo.whl and copy all the prebuilt GTK DLLs to your environment.
Then, you can fix the DLL module path by import this module.
import platform
try:
from pygobject_prebuilt_deps import import_pygobject_dll_module
import_pygobject_dll_module()
except ImportError:
pass
import gi
import cairo
gi.request_version("GTK", "3.0")
Then import_pygobject_dll_module
function will add DLLs path to os.environ['PATH']
and setup the GI_TYPELIB_PATH
environment, so that you can easily to import gi and cairo.
Prebuilt PyGobject version: 3.42.2
Prebuilt PyCairo version: 1.21.0