Search code examples
python-3.xgtkanacondagtk3pygobject

How to install PyGObject on windows in a anaconda virtual env


I want to use Gtk with python under windows. I already have Anaconda installed on windows. In order not to mess up everything and to have some easiness uninstalling/reinstalling, I would like to have a virtual env created with conda, working with that Gtk installation. But I don't seems to be able to make it work.

Here is my process. I first create a raw Ananconda virtual env with

conda create -n gtk-exporter python

The virtual environment is located at C:\Anaconda3\envs\gtk-exporter.

I then download the latest windows installer for PyGObject at http://sourceforge.net/projects/pygobjectwin32/files/?source=navbar

I extract and execute the installer and tell it to use a portable python install at C:\Anaconda3\envs\gtk-exporter. I only select Base, GTK and Glade for installation. The installation finished in a second and says it's successful.

Then within windows' shell, I activate the new environment with activate gtk-exporter. However when I try to import gtk, it fails, not finding gi.repository.

>>> from gi.repository import Gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'gi'

What's wrong here ? C:\Anaconda3\envs\gtk-exporter\Lib\site-package contains a folder gnome with a lot of stuff including *.dlls, *.exe's and unix-looking folders like etc, lib or share, but I don't see a init.py or something pythonic. Am I missing a step.

Thank you for your help !


Solution

  • The problem was that I used python 3.5, whereas it is not supported. The installer should not have allowed me to install with python 3.5. I filed a bug report to signal it.

    I solved the problem by uninstalling python 3.5 and installing python 3.4.