python - 在某些系统上提供 URL 时,launch_default_for_uri() 会引发异常
问题描述
我正在使用launch_default_for_uri
from Gio
(imported from 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
应该会有所帮助。
推荐阅读
- nativescript - Nativescript - 卸载框架
- html - 如何匿名从 Swift 中的 URL 获取 HTML 源代码?
- nuxt.js - 错误:更新 nuxt 到 v2.3.4 后的循环依赖
- intellij-idea - 在调试中禁用 PhpStorm 中的 vim 模式
- drools - 是否可以在流口水规则中返回异常?
- angular - 如何使用 *ngFor 和 *ngIf 循环多个 tr
- mysql - 如何在同一日期减去同一列中的两行?
- jenkins - jenkins Nexus 平台插件 3.x 未发生 Nexus 连接
- java - 古巴平台中的谷歌日历API:无法从最终类继承
- dialogflow-es - Dialogflow Fulfillment:修复聊天机器人响应