1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

github actionで`qt.qpa.xcb could not connect to display`

Posted at

github actionでPyQt5を使ったアプリをテストするも、qt.qpa.xcb could not connect to displayでエラーになってしまった。

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.
start.sh: line 40:  2323 Aborted                 (core dumped) python3 game_manager/game_manager.py --game_time ${GAME_TIME} --seed ${RANDOM_SEED} --obstacle_height ${OBSTACLE_HEIGHT} --obstacle_probability ${OBSTACLE_PROBABILITY} --drop_speed ${DROP_SPEED} --manual ${IS_MANUAL_CONTROLL} --use_sample ${IS_SAMPLE_CONTROLL}
Error: Process completed with exit code 134.

以下の通り、workflow上で環境変数追加と、xvfbをインストールして解決。

# 環境変数
env:
  DISPLAY: ':99'
      - name: Xvfb install and run
        run: |
          sudo apt-get install -y xvfb
          Xvfb -ac ${{ env.DISPLAY }} -screen 0 1280x780x24 &

以下は今回作成した.yamlファイルの全体、ご参考。

.github/workflows/test.yaml
name: Python package
      
on: [push]

# 環境変数
env:
  DISPLAY: ':99'

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.5, 3.6, 3.7, 3.8]

    steps:
      - uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install flake8 pytest
          sudo apt-get install -y python3-pip
          pip3 install --upgrade pip
          pip3 install numpy
          pip3 install PyQt5
          sudo apt-get install -y python3-pyqt5
          sudo apt-get install -y git
          sudo apt-get install -y jq
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
      - name: Lint with flake8
        run: |
          # stop the build if there are Python syntax errors or undefined names
          flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
          # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
          flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
      - name: Display Python version
        run: python -c "import sys; print(sys.version)"
      # xvfbのインストールと起動
      - name: Xvfb install and run
        run: |
          sudo apt-get install -y xvfb
          Xvfb -ac ${{ env.DISPLAY }} -screen 0 1280x780x24 &
      - name: tetris_game
        run: |
          git clone https://github.com/seigot/tetris_game
          cd tetris_game
          bash start.sh -s y -t 3

参考

Usage on GitHub Actions with xvfb

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?