I am trying to install PyGtk on windows 7 for Python 2.7, but when go to use pip to install PyGtk it says I need PyGObject so I installed the Visual C++ package for Python (I know I have the correct version) and tried using pip to install PyGObject, but it keeps coming out with an error message saying that cairo.h is missing, and sure enough I check in the directory and it wasn't there. How am I supposed to install PyGObject?
There's a quite long way, and it needs some tweaking here and there, but it works. I used Python 3.6, and don't know whether it will work in 2.7.
First, get build scripts for GTK+3 for Windows from guruDanny67/gvsbuild. It's a fork from wingtk/gvsbuild, but it seems to be more up-to-date with the various versions of packages. I used the 'ed2018' branch, which seems to be the most relevant, but the changes from this branch will probably end in 'master', so check the number of commits ahead and behind.
You will also need a Visual Studio 2017 build tools if you don't have C++ workload installed in Visual Studio 2017. You can also use VS 2015, but I didn't try it. 2017 Build tools are here: https://visualstudio.microsoft.com/downloads/#other. You should probably also include 'VC++ 2015.3 v14.00 toolset for desktop'.
You'll need a Python installed. I used version 3.6, don't know about the others.
Also, you'll need MSYS2 (http://www.msys2.org/). It's only used for some needed tools.
The compiling/installation is (mostly) quite straightforward, but it takes some time (SSD probably helps a lot). Just read the instructions on the gvsbuild page. If you build piece by piece, it helps to include --fast-build
parameter in the command line.
You can get the list of all projects than can be build using
python build.py list
or simply
build list
if you have a Python launcher installed.
All the options for build:
build build --help
There's a build project for a pygobject and pycairo, which installs them in the installed Python site-packages
directory. However, the better way is to uninstall them (use pip
or just remove directories if pip complains).
Then, download the sources for the PyCairo and PyGObject from the PyPi site (https://pypi.org/project/pycairo/, https://pypi.org/project/PyGObject/). Add the directory with the bunch of lib
files to your LIB
environment variable (should be something like f:\gtk-build\gtk\Win32\release\lib
). Add the include directory to your INCLUDE
environment variable (c:\gtk-build\gtk\Win32\release\include
), and run the setup build
script for the Cairo first. If build finished OK, run setup bdist_wininst
. It will generate an installation exe file in the dist
subdirectory. Run this exe (as an administrator), and you should have PyCairo installed.
The build for the PyGobject is the same.
If the setup build
complains that it cannot find some .lib
or .include
file, just find which folder are they in, somewhere in your gtk-build\gtk\Win32\release\' folder. Include that folder in
LIBor
INCLUDE` variable and run again.
© 2022 - 2024 — McMap. All rights reserved.