我在哪里可以找到python Zeitgeist Programming模块?

时间:2017-03-29 13:43:22

标签: python zeitgeist

在Zeitgeist launchpad page上,为初学者提供了link to a python API tutorial

我已经从启动板站点完全配置并安装了zeitgeist-1.0 tarball,但在python编程时我仍然无法找到或使用zeitgeist模块。
 请帮忙。 编辑:
我还没有尝试任何东西,我刚刚安装了整个包装。我还安装了以下软件包。 libzeitgeist-1.0-1:amd64 libzeitgeist-2.0-0:amd64 python-zeitgeist rhythmbox-plugin-zeitgeist zeitgeist zeitgeist-core zeitgeist-datahub zeitgeist-explorer。

我也在ipython3上使用python 3.5。

1 个答案:

答案 0 :(得分:0)

您必须安装 python-zeitgeist 模块:

pip install --user python-zeitgeist

sudo apt-get install python-zeitgeist

查看示例代码,看看here

from zeitgeist.client import ZeitgeistClient
from zeitgeist.datamodel import *

zeitgeist = ZeitgeistClient()

def on_events_received(events):
    if events:
        song = events[0]
        print "Last song: %s" % song.subjects[0].uri
    else:
        print "You haven't listened to any songs."

template = Event.new_for_values(subject_interpretation=Interpretation.AUDIO)
zeitgeist.find_events_for_template(template, on_events_received, num_events=1)

# Start a mainloop - note: the Qt mainloop also works
from gi.repository import GLib
GLib.MainLoop().run()