Search code examples
python-3.xxvfb

pyvirtual display and xvfb on MacOS latest


Context

I am trying to get some code working on MacOS. The code uses the Mayavi visualization library, and is supposed to run on headless servers to produce visualizations.

Dependencies

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

And then I install the desired library:

python3 -m pip install PyVirtualDisplay

But this does not seem to work on the Github Action remote:

The error:

  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 ===============================

Solution

  • brew install --cask xquartz
    
    # in your ~/.zshrc
    export PATH=$PATH:/opt/X11/bin