Python cannot install PyGObject
For windows
- Go to http://www.msys2.org/ and download the x86_64 installer
- Follow the instructions on the page for setting up the basic environment
- Run
C:\msys64\mingw32.exe
- a terminal window should pop up - Execute
pacman -Suy
- Execute
pacman -S mingw-w64-i686-gtk3 mingw-w64-i686-python3-gobject
- To test that GTK 3 is working you can run
gtk3-demo
- Copy the
hello.py
script you created toC:\msys64\home\<username>
- In the mingw32 terminal execute
python3 hello.py
- a window should appear.
For ubuntu / Debian
Installing the system provided PyGObject:
- Open a terminal
- Execute
sudo apt install python3-gi python3-gi-cairo gir1.2-gtk-3.0
- Change the directory to where your
hello.py
script can be found (e.g.cd Desktop
) - Run
python3 hello.py
Installing from PyPI with pip:
- Open a terminal and enter your virtual environment
- Execute
sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0
- Execute
pip3 install pycairo
to build and install Pycairo - Execute
pip3 install PyGObject
to build and install PyGObject - Change the working directory to where your
hello.py
script can be found - Run
python3 hello.py
You can read more here
Since February 2017, you can install pygobject directly through pip: pip install pygobject
. It requires some packages to be installed though.
Before that, it took a while, but it was possible to install pygobject with pip, since this commit.
pygobject wasn't on pypi though, so you had to specify the git or tarball URL:
git+https://git.gnome.org/browse/pygobject
https://download.gnome.org/sources/pygobject/3.22/pygobject-3.22.0.tar.xz
The latter only works with pygobject 3.22+, which should have happenned around mid-september 2016. (3.21.1 should be the first pip-installable development release)