Week 3 Lunar Landing

I want to replicate the code for Lunar Lander but have become stuck on this line of code Display(visible=False, size=(840, 480)).start();

I ensured that I loaded the same library version as the course
pip install pyvirtualdisplay==3.0

First I was using ‘google colab’ but that cannot handle Display(visible=False, size=(840, 480)).start(); It did import ‘pyvirtualdisplay’ with no problems. Error message was FileNotFoundError: [Errno 2] No such file or directory: 'Xvfb'.

From what I can understand ‘Xvfb’ is a virtual server that will store pixel values in buffered memory that I can extract and save later as a mp4 file. Google Colab cannot do that.

So I opened Jupyter Notebook and entered the same code. Error this time was FileNotFoundError: [WinError 2] The system cannot find the file specified

So then I tried running it in Pycharm Community, on my PC, and received this error FileNotFoundError: [WinError 2] The system cannot find the file specified.

What step should I take to correct the errors?

I even tried this simple piece of code but encountered the same problem.

import pyvirtualdisplay
d = pyvirtualdisplay.Display()
d.start() # Start Xvfb and set "DISPLAY" environment properly.

and tried these options as well
d=Display()

or

d=Display(visible=False)

or

d=Display(backend="xvfb")

but all the same error code as mentioned above.

To run the notebook on Google Colab, you need to install some additional packages. You can do this by executing the following commands in a code cell:

!pip install pyvirtualdisplay
!pip install Box2D
!apt install xvfb
1 Like