OSError: Pillow was built without XCB support

I am trying to record a video of the agent, while testing:

python train.py task=ShadowHand num_envs=1 test=True checpoint=path capture_video=True

The code crashes at the render() call in the vec_task.py script when a function is called to grab the image and store it in the img variable:

img=self.virtual_display.grab()

How do I fix this?
I have tried updating Pillow
I am on Ubuntu 22.04

I met the same problem in Ubuntu 20.04. I solved it by reinstall PIL with XCB support following the instructions in Pillow website (Installation - Pillow (PIL Fork) 10.0.1 documentation).

More specifically, first install the external libraries: sudo apt-get install libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \ libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \ libharfbuzz-dev libfribidi-dev libxcb1-dev. Then reinstall Pillow with python3 -m pip install --upgrade Pillow --no-binary :all:.

The answer is probably too late now, but hopefully this will help future users.