pyvirtual display and xvfb on MacOS latest

问题描述 投票:0回答:2

上下文

我正在尝试让一些代码在 MacOS 上运行。该代码使用 Mayavi 可视化库,并且应该在无头服务器上运行以生成可视化效果。

依赖关系

brew install gdal
brew install xdpyinfo
brew install --cask xquartz

然后我安装所需的库:

python3 -m pip install PyVirtualDisplay

但这似乎不适用于 Github Action 遥控器:

错误:

  display = Display(visible=0, size=(1280, 1024))
/usr/local/lib/python3.9/site-packages/pyvirtualdisplay/display.py:54: in __init__
    self._obj = cls(
/usr/local/lib/python3.9/site-packages/pyvirtualdisplay/xvfb.py:44: in __init__
    AbstractDisplay.__init__(
/usr/local/lib/python3.9/site-packages/pyvirtualdisplay/abstractdisplay.py:85: in __init__
    helptext = get_helptext(program)
/usr/local/lib/python3.9/site-packages/pyvirtualdisplay/util.py:13: in get_helptext
    p = subprocess.Popen(
/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py:951: in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py:1821: in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
E   FileNotFoundError: [Errno 2] No such file or directory: 'Xvfb'
=========================== short test summary info ============================
ERROR test_animate.py - FileNotFoundError: [Errno 2] No such file or director...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
============================== 1 error in 27.12s ===============================
python-3.x xvfb
2个回答
0
投票

按照 PyVirtualDisplay 定义的 github 工作流程,解决方案是执行以下命令(对于 github 操作):

    - name: Install MacOS dependencies
      if: startsWith(matrix.os, 'macos')
      run: |
        brew install --cask xquartz
        # https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#adding-a-system-path
        echo "/opt/X11/bin" >> $GITHUB_PATH  
        # https://github.com/ponty/PyVirtualDisplay/issues/42
        mkdir /tmp/.X11-unix
        sudo chmod 1777 /tmp/.X11-unix
        sudo chown root /tmp/.X11-unix

0
投票
brew install --cask xquartz

# in your ~/.zshrc
export PATH=$PATH:/opt/X11/bin
© www.soinside.com 2019 - 2024. All rights reserved.