Ubuntu – Import python bindings for meta Tracker introspection

pythonsearchtracker

When I try to run the metaTracker introspection examples or import the Tracker module in iPython console I get an import error. Googling for this particular error message doesn't turn up anything except the patch that created these supposedly working examples for meta Tracker in 2012.

Python 2.7.4 (default, Apr 19 2013, 18:28:01) 
IPython 0.13 -- An enhanced Interactive Python.

In [1]: import gi
In [2]: from gi.repository import Tracker, GObject
ERROR:root:Could not find any typelib for Tracker
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-0b29c3277539> in <module>()
----> 1 from gi.repository import Tracker, GObject

ImportError: cannot import name Tracker

And what is a typelib and how do I install or import one for Tracker?

Best Answer

To search for any libraries that might be needed for tracker I did:

sudo apt-cache search tracker | grep meta

which turned up the following leads:

libtracker-sparql-0.14-0 - metadata database, indexer and search tool - library
libtracker-sparql-0.14-dev - metadata database, indexer and search tool - development files
libtracker-sparql-doc - metadata database, indexer and search tool - API documentation
mktorrent - simple command line utility to create BitTorrent metainfo files
tracker - metadata database, indexer and search tool
tracker-dbg - metadata database, indexer and search tool - debugging symbols
tracker-explorer - metadata database, indexer and search tool - developer tool
tracker-extract - metadata database, indexer and search tool - metadata extractors
tracker-gui - metadata database, indexer and search tool - GNOME frontends
tracker-miner-fs - metadata database, indexer and search tool - filesystem indexer
tracker-utils - metadata database, indexer and search tool - commandline tools

I'd already done a sudo apt-get install tracker* so I wasn't missing any of the core utilities or debug symbols so the next obvious lead was...

sudo apt-get install libtracker-*

which installed ever thing I could possibly need:

The following NEW packages will be installed:
  gir1.2-tracker-0.14 libtracker-extract-0.14-dev libtracker-extract-doc libtracker-miner-0.14-dev libtracker-miner-doc libtracker-sparql-0.14-dev libtracker-sparql-doc

and fixed the import error:

Python 2.7.4 (default, Apr 19 2013, 18:28:01) 
IPython 0.13 -- An enhanced Interactive Python.

In [1]: import gi
In [2]: from gi.repository import Tracker, GObject
In [3]: %run tracker/examples/introspection/python/all-async.py
('http://www.semanticdesktop.org/ontologies/2007/03/22/nco#default-contact-me', 75L)
('http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#roi-content-face', 73L)
('http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#roi-content-pet', 72L)
('http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#roi-content-focus', 74L)
('http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#roi-content-barcode', 76L)
('http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#roi-content-undefined', 78L)
Related Question