导入 Python 绑定以进行元跟踪器自省

导入 Python 绑定以进行元跟踪器自省

当我尝试运行 metaTracker 自省示例或在 iPython 控制台中导入 Tracker 模块时,我收到导入错误。在 Google 上搜索此特定错误消息,除了 2012 年为 meta Tracker 创建这些据称可以工作的示例的补丁外,没有找到任何内容。

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

什么是类型库以及如何为 Tracker 安装或导入类型库?

答案1

为了搜索跟踪器可能需要的任何库,我做了:

sudo apt-cache search tracker | grep meta

得出的线索如下:

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

我已经做了,sudo apt-get install tracker*所以我没有错过任何核心实用程序或调试符号,所以下一个明显的线索是......

sudo apt-get install libtracker-*

安装了我可能需要的所有东西:

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

并修复了导入错误:

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)

相关内容