ubuntu 16.10 如何安裝ldtp

很簡單

sudo apt-get update
sudo apt-get install ldtp

驗證ldtp
在python命令行

>>> import ldtp
>>> from ldtp import *
>>> guiexist('-gedit')
0

但是報錯:

/usr/local/lib/python2.7/dist-packages/ldtpd/core.py:29: PyGIWarning: Wnck was imported without specifying a version first. Use gi.require_version('Wnck', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Wnck as wnck

解決方法:
那就到/usr/local/lib/python2.7/dist-packages/ldtpd/core.py代碼的29行改一下,在第二十九行之前加一句代碼

  import gi
  gi.require_version('Wnck', '3.0')

結果,代碼如下圖所示

try:
  # If we have gtk3+ gobject introspection, use that
  import gi
  gi.require_version('Wnck', '3.0')
  from gi.repository import Wnck as wnck
  from gi.repository import Gtk as gtk
  from gi.repository import Gdk as gdk
  wnckModule=gtk3=True
發佈了52 篇原創文章 · 獲贊 53 · 訪問量 13萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章