安装 kazam 屏幕投射软件后,它无法启动。
我正在使用 Ubuntu 17.04。
/usr/bin/kazam:32: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk
/usr/lib/python3/dist-packages/kazam/frontend/window_area.py:30: 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 Gtk, GObject, Gdk, Wnck, GdkX11
/usr/lib/python3/dist-packages/kazam/backend/gstreamer.py:35: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded.
from gi.repository import GObject, Gst
/usr/lib/python3/dist-packages/kazam/frontend/indicator.py:148: PyGIWarning: AppIndicator3 was imported without specifying a version first. Use gi.require_version('AppIndicator3', '0.1') before import to ensure that the right version gets loaded.
from gi.repository import AppIndicator3
/usr/lib/python3/dist-packages/kazam/frontend/indicator.py:97: PyGIWarning: Keybinder was imported without specifying a version first. Use gi.require_version('Keybinder', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Keybinder
Segmentation fault (core dumped)
答案1
只需安装即可python3-xlib
解决 Kazam 的特定分段错误问题,但您可能注意到仍然有几个关于导入“未先指定版本”的 PyGI 警告。
由于这个问题是谷歌关于此类警告的第一名(这就是我在这里偶然发现的),这就是如何更改代码以防止此类警告,正如警告本身所述。
代替:
from gi.repository import Gtk, GObject, Gdk, Wnck, GdkX11, Gst, AppIndicator3
这会发出几个警告:
__main__:1: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
__main__:1: 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.
__main__:1: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded.
__main__:1: PyGIWarning: AppIndicator3 was imported without specifying a version first. Use gi.require_version('AppIndicator3', '0.1') before import to ensure that the right version gets loaded.
使用这个,根据官方PyGOobject 文档:
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Wnck', '3.0')
gi.require_version('Gst', '1.0')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk, GObject, Gdk, Wnck, GdkX11, Gst, AppIndicator3
显然,并非所有的gi
子模块都需要指定版本。
或者,您也可以使用以下语句在一条语句中要求所有版本require_versions()
函数(注意是复数),它采用单个模块词典及其各自的版本:
import gi
gi.require_versions({
'Gtk': '3.0',
'Wnck': '3.0',
'Gst': '1.0',
'AppIndicator3': '0.1',
})
from gi.repository import Gtk, GObject, Gdk, Wnck, GdkX11, Gst, AppIndicator3
此功能未在官方文档中列出,但它是在PyGObject 3.21.0于 2016 年发布。
答案2
此段错误的问题出在 Kazam 热键绑定中。也许系统无法将某些键绑定提供给 Kazam,因此我们得到了异常。
粗略的解决方案是删除 Kazam 的全局键绑定:
打开文件:
/usr/lib/python3/dist-packages/kazam/frontend/indicator.py
找到这些字符串(大约第 100 行左右):
Keybinder.bind("<Super><Ctrl>R", self.cb_hotkeys, "start-request") Keybinder.bind("<Super><Ctrl>F", self.cb_hotkeys, "stop-request") Keybinder.bind("<Super><Ctrl>P", self.cb_hotkeys, "pause-request") Keybinder.bind("<Super><Ctrl>W", self.cb_hotkeys, "show-request") Keybinder.bind("<Super><Ctrl>Q", self.cb_hotkeys, "quit-request")
将其注释掉:
#Keybinder.bind("<Super><Ctrl>R", self.cb_hotkeys, "start-request") #Keybinder.bind("<Super><Ctrl>F", self.cb_hotkeys, "stop-request") #Keybinder.bind("<Super><Ctrl>P", self.cb_hotkeys, "pause-request") #Keybinder.bind("<Super><Ctrl>W", self.cb_hotkeys, "show-request") #Keybinder.bind("<Super><Ctrl>Q", self.cb_hotkeys, "quit-request")
保存文件。
运行 Kazam。
你真棒。
此后,您将无法使用这些热键,但至少 Kazam 可以工作。
答案3
已解决:我只需要安装 python3-xlib:
sudo apt-get update
sudo apt-get install python3-xlib
答案4
您可以简单地使用:
pip install --upgrade --force-reinstall kazam