首页 > 解决方案 > 你可以在没有模拟的情况下在 ReadTheDocs 构建中使用 QT 吗?

问题描述

我们的项目使用 QT ( PySide2, qtpy) 并使用 sphinx autodoc 记录在 ReadTheDocs 上。到目前为止,我们已经模拟了大多数依赖项,但在这种特定情况下,模拟qtpy非常复杂。我希望conda通过python.readthedocs.yml.

安装似乎工作正常,但我在 RTD 构建的 sphinx-build 步骤中遇到错误:

qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Fatal Python error: Aborted

回溯指向我们代码中的行:QT_APP = QApplication(sys.argv).

我尝试了设置QT_DEBUG_PLUGINS=1,它提供了一些我无法做出任何事情的输出:

...
Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/bin/platforms" ...
loaded library "/home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/lib/python3.8/site-packages/PySide2/Qt/plugins/platforms/libqeglfs.so"
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-docs'
QFactoryLoader::QFactoryLoader() checking directory path "/home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/lib/python3.8/site-packages/PySide2/Qt/plugins/egldeviceintegrations" ...
QFactoryLoader::QFactoryLoader() looking at "/home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/lib/python3.8/site-packages/PySide2/Qt/plugins/egldeviceintegrations/libqeglfs-emu-integration.so"
Found metadata in lib /home/docs/checkouts/readthedocs.org/user_builds/invest/conda/395/lib/python3.8/site-packages/PySide2/Qt/plugins/egldeviceintegrations/libqeglfs-emu-integration.so, metadata=
{
    "IID": "org.qt-project.qt.qpa.egl.QEglFSDeviceIntegrationFactoryInterface.5.5",
    "MetaData": {
        "Keys": [
            "eglfs_emu"
        ]
    },
    "archreq": 0,
    "className": "QEglFSEmulatorIntegrationPlugin",
    "debug": false,
    "version": 331520
}
...

而且我尝试通过设置更改平台插件QT_QPA_PLATFORM=eglfs,这给出了类似的错误Could not initialize egl display:谷歌搜索错误主要是与 Raspberry Pi 相关的问题。

发生这种情况是因为运行构建的虚拟机实际上没有显示器吗?有没有办法解决?

标签: pythonpython-sphinxpyside2read-the-docsxcb

解决方案


发生这种情况是因为运行构建的虚拟机实际上没有显示器吗?

我猜“是”。错误应该是Qt连接X11显示器失败。

有没有办法解决?

您可以尝试在xvfb-run. 因此,foo您将运行而不是运行xvfb-run。这将设置一个无头 X11 服务器。


推荐阅读