我使用 Mayavi 在我的 python3 庫中撰寫了一堆可視化函式。我對這個庫不是很熟悉,也不是使用 python 測驗可視化。
理想情況下,我只希望可視化代碼在磁盤上生成一些圖形,我不太關心彈出視窗(盡管我不確定 Mayavi 是否可以在不彈出此類視窗的情況下正常作業)。
無論如何,我的代碼在本地作業,但是當我將其推送到開發時,CircleCI 無法運行測驗并出現以下錯誤:
!/bin/bash -eo pipefail
python3 tests/test.py
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.
Received "aborted" signal
我使用的 Docker 鏡像如下:
FROM ubuntu:focal
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y
RUN apt-get install -y --no-install-recommends\
vim \
git \
gcc-9 \
g \
build-essential \
libboost-all-dev \
cmake \
unzip \
tar \
ca-certificates \
doxygen \
graphviz
RUN apt-get install -y libgdal-dev g --no-install-recommends && \
apt-get clean -y
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal
RUN git clone --recurse-submodules https://github.com/Becheler/quetzal-EGGS \
&& cd quetzal-EGGS \
&& mkdir Release \
&& cd Release \
&& cmake .. -DCMAKE_INSTALL_PREFIX="/usr/local/quetzal-EGGS" \
&& cmake --build . --config Release --target install
RUN set -xe \
apt-get update && apt-get install -y \
python3-pip \
--no-install-recommends
RUN pip3 install --upgrade pip
RUN pip3 install build twine pipenv numpy # for crumbs publishing
RUN pip3 install rasterio && \
pip3 install matplotlib && \
pip3 install imageio && \
pip3 install imageio-ffmpeg && \
pip3 install pyproj && \
pip3 install shapely && \
pip3 install fiona && \
pip3 install scikit-learn && \
pip3 install pyimpute && \
pip3 install geopandas && \
pip3 install pygbif
########## MAYAVI
# xcb plugin
RUN apt-get install -y --no-install-recommends libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 && \
apt-get clean -y
RUN python3 -m pip install vtk
RUN apt-get update && apt-get install -y python3-opencv && apt-get clean -y
RUN pip3 install opencv-python
RUN pip3 install mayavi PyQt5
RUN pip3 install GDAL==$(gdal-config --version) pyvolve==1.0.3 quetzal-crumbs==0.0.15
# Clean to make image smaller
RUN apt-get autoclean && \
apt-get autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
- 我是否缺少一些依賴項?
- 我應該在
-X某個地方有選擇嗎? - 我應該在我的庫中停用
mlab.show()和imshow()呼叫嗎?
uj5u.com熱心網友回復:
我錯過了一個依賴,qt5-default. 我最終得到了在 Docker/CircleCi 上運行 Mayavi 的這些行:
########## MAYAVI
# xcb plugin
RUN apt-get install -y --no-install-recommends xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 && \
apt-get clean -y
# Trying to solve the weird xcfb error
RUN apt-get install -y --no-install-recommends qt5-default && \
apt-get clean -y
RUN python3 -m pip install vtk
RUN apt-get update && apt-get install -y python3-opencv && apt-get clean -y
RUN pip3 install opencv-python
RUN pip3 install PyVirtualDisplay
RUN pip3 install mayavi PyQt5
我很確定這些依賴項中有許多是多余的或不需要的。但它有效,所以我會保持這種狀態,直到我有時間做一些清理作業。
我還在我的 python 庫中添加了這一行:
mlab.options.offscreen = True
它的理由來自mayavi 離屏渲染檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/424117.html
