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