I try install pygobject by pip
pip install --user PyGObject
but I doesn\'t work:
Collecting PyGObject
Using cached pygob
C:\msys64\mingw32.exe
- a terminal window should pop uppacman -Suy
pacman -S mingw-w64-i686-gtk3 mingw-w64-i686-python3-gobject
gtk3-demo
hello.py
script you created to C:\msys64\home\<username>
python3 hello.py
- a window should appear.sudo apt install python3-gi python3-gi-cairo gir1.2-gtk-3.0
hello.py
script can be found (e.g. cd Desktop
)python3 hello.py
sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0
pip3 install pycairo
to build and install Pycairopip3 install PyGObject
to build and install PyGObjecthello.py
script can be foundpython3 hello.py
Upstream PyGObject just does not support this. See the PyGObject win32 project or the MSYS2 project to get it easily.
I'll just add what I've been using to make this work seamlessly in various projects.
It uses GNU Make, by providing a venv
target one can use as a dependency to other targets to ensure a properly created virtual environment.
The venv
target itself depends on a, albeit configurable, requirements.txt
; the standard python requirements file.
A target test
is include as an example of how one would use this.
The trick is to create a symlink to the installed system package. ln -s ${DIST_PACKAGES}/gi ${VENV_NAME}/lib/python${PYTHON_VER}/site-packages/gi
, where $DIST_PACKAGE
is the location of the python installed libraries on your system.
For those not familiar with make. Create a file named Makefile
in the root of your project, copy the contents bellow, and issue the command make configure && make venv
.
Makefile
# directory to store virtual environment
VENV_NAME=venv
# python runtime version
PYTHON_VER=3.6
# python executble
PYTHON=${VENV_NAME}/bin/python${PYTHON_VER}
# python local libraries location
DIST_PACKAGES=/usr/lib/python3/dist-packages
# pip requirements file
REQUIREMENTS=requirements.txt
configure: ## Install required debian packages.
sudo apt-get -y install python${PYTHON_VER} python3-pip libgirepository1.0-dev
python3 -m pip install virtualenv pygobject
make venv
venv: ## Recreates the virtual environment if needed.
venv: $(VENV_NAME)/bin/activate
$(VENV_NAME)/bin/activate: ${REQUIREMENTS}
test -d $(VENV_NAME) || virtualenv -p python${PYTHON_VER} $(VENV_NAME)
${PYTHON} -m pip install -U pip
${PYTHON} -m pip install -r ${REQUIREMENTS}
ln -s ${DIST_PACKAGES}/gi ${VENV_NAME}/lib/python${PYTHON_VER}/site-packages/gi
touch $@
test: ## Runs the test suite.
test: venv
$(PYTHON) -m pytest tests
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)