using GTKAgg backend on python 3.5 (anaconda) and centos 7

642 Views Asked by At

I tried to use GTKAgg as back-end for matplotlib package.

matplotlib.use('GTKAgg')
Failed to enable GUI event loop integration for 'gtk'
Traceback (most recent call last):
  File "/home/oshri/.pycharm_helpers/pydev/_pydev_bundle/pydev_console_utils.py", line 569, in do_enable_gui
    enable_gui(guiname)
  File "/home/oshri/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 528, in enable_gui
    return gui_hook(app)
  File "/home/oshri/.pycharm_helpers/pydev/pydev_ipython/inputhook.py", line 244, in enable_gtk
    from pydev_ipython.inputhookgtk import create_inputhook_gtk
  File "/home/oshri/.pycharm_helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/home/oshri/.pycharm_helpers/pydev/pydev_ipython/inputhookgtk.py", line 19, in <module>
    import gtk, gobject  # @UnresolvedImport
  File "/home/oshri/.pycharm_helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: No module named 'gtk'

I tried to install the gtk using conda, using this repo, the conda outputs that the package is installed.

import conda.cli
conda.cli.main('conda','install','-c','ska','pygtk=2.16.0')
Fetching package metadata .............
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /data/anaconda:
#
pygtk                     2.16.0                        0    ska

When I tried to install the pygtk using pip I got this error.

[oshri@analytics ~]$ pip install pygtk 
Collecting pygtk
  Using cached pygtk-2.24.0.tar.bz2
    Complete output from command python setup.py egg_info:
    ********************************************************************
    * Building PyGTK using distutils is only supported on windows. *
    * To build PyGTK in a supported way, read the INSTALL file.    *
    ********************************************************************

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-x78h7u1k/pygtk/

When I tried to use python2.7 I success to import the model.

[oshri@analytics ~]$ /bin/python2.7
Python 2.7.5 (default, Nov  6 2016, 00:28:07) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygtk 
>>> exit()

For this reason I think that the issue is related to the python version. I tried to use this guide but I didn't succeed to use JHBuild.

[oshri@analytics ~]$ jhbuild build pygobject
Required packages:
  System installed packages which are too old:
    (none)
  No matching system package installed:
    itstool 
    libffi (libffi.pc, required=3.0.0)
    python3-devel (python3.pc, required=3.2)
    libxslt (libxslt.pc, required=1.1.26)
    cairo (cairo.pc, required=1.14.0)
    libxml2 (libxml-2.0.pc, required=2.7.8)
jhbuild build: Required system dependencies not installed. Install using the command 'jhbuild sysdeps --install' or to ignore system dependencies use command-line option --nodeps
[oshri@analytics ~]$ jhbuild build sysdeps --install pygobject
Usage: jhbuild build [ options ... ] [ modules ... ]

jhbuild: error: no such option: --install
[oshri@analytics ~]$ jhbuild sysdeps --install pygobject
System installed packages which are new enough:
    zlib (zlib.pc, installed=1.2.7)
    automake 
    docbook-xml 
    docbook-xsl 
    libtool 
    pkg-config 
    cc 
    make 
    git 
    xmlcatalog 
    bison (required=2.4)
    intltool (required=0.50.2)
    xmllint 
    xsltproc 
    libpcre (libpcre.pc, required=8.31, installed=8.32)
    flex (required=2.0)
Required packages:
  System installed packages which are too old:
    (none)
  No matching system package installed:
    itstool 
    libxml2 (libxml-2.0.pc, required=2.7.8)
    libxslt (libxslt.pc, required=1.1.26)
    cairo (cairo.pc, required=1.14.0)
    libffi (libffi.pc, required=3.0.0)
    python3-devel (python3.pc, required=3.2)
Optional packages: (JHBuild will build the missing packages)
  System installed packages which are too old:
    (none)
  No matching system package installed:
I: Installing dependencies on system: itstool libxml2 libxslt cairo libffi python3-devel
I: Computing packages to install. This might be slow. Please wait.
I: Installing:
  itstool;1.2.0-4.el7;noarch;base
  libffi-devel;3.0.13-18.el7;x86_64;base
  python34-devel;3.4.5-4.el7;x86_64;epel
  cairo-devel;1.14.2-1.el7;x86_64;base
  libxml2-devel;2.9.1-6.0.1.el7_2.3;x86_64;ol7_latest
  libxslt-devel;1.1.28-5.0.1.el7;x86_64;ol7_latest
I: This might take a very long time. Do not turn off your computer. You can run `pkmon' to monitor progress.
E: PackageKit: Failed to obtain authentication.
I: Complete!
[oshri@analytics ~]$ sudo jhbuild sysdeps --install pygobject
[sudo] password for oshri: 
sudo: jhbuild: command not found
  1. I'm right that issues related to python version?
  2. Should I install JHBuild under root user?
0

There are 0 best solutions below