在 Zeitgeist启动板页面 上,为初学者提供了 Python API 教程的链接。
我已经从启动板站点完全配置并安装了 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。
你必须安装python-zeitgeist模块:
pip install --user python-zeitgeist
或者
sudo apt-get install python-zeitgeist
寻找示例代码,看看这里
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()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句