问题描述
我正在使用launch_default_for_uri
(从Gio
导入的gi.repository
函数在用户的默认浏览器中打开URL。在运行postmarketoS的手机和运行Fedora 32的台式机上,此方法效果很好,但是在Alpine Linux虚拟机中,运行它却引发以下异常:
Traceback (most recent call last):
File "giotest.py",line 3 in <module>
Gio.AppInfo.launch_default_for_uri("https://stackoverflow.com")
gi.repository.GLib.Error: g-io-error-quark: Operation not supported (15)
这是我最小的可重现示例:
from gi.repository import Gio
Gio.AppInfo.launch_default_for_uri("https://stackoverflow.com")
我想这可能是由于我的虚拟机中缺少依赖项引起的,但是我不确定那是什么。我该怎么做才能在虚拟机上完成这项工作?
解决方法
您可能缺少GIO后端:安装gvfs
应该会有所帮助。
事实证明,至少在我看来,这是因为我没有设置默认的浏览器。通过Firefox的设置将Firefox设置为默认设置可以解决此问题。