当前位置: 首页 > 工具软件 > LDTP > 使用案例 >

ubuntu 16.10 如何安装ldtp

况安然
2023-12-01

很简单

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
 类似资料: