Error with pyvirtualdisplay.Display for the Assignment

Hi all,

I was trying to practice with the W3 Assignment 1 with Lunar Lander with my local jupyter notebook and am keep facing the following error with pyvirtualdisplay.Display.
I am runnng on Windows 11 and not sure if how I can resolve this after tons of googling.

Sounds like maybe you don’t have all of the assignment assets installed on your computer.

Actually I have them installed all…

I don’t have any other ideas on this.

Hello @sjerin ,

image

Your screenshot said “Output is truncated”. Perhaps there is something else that worths our attention. The key is to find out what file is missing. Please share the whole output.

Cheers,
Raymond

Hello @rmwkwok

Thank you for your consideration and help, the below is the entire output:
(FYI, I had all the files needed for this practice lab in the my working directory and had the packages installed as well)


FileNotFoundError Traceback (most recent call last)
Cell In[10], line 2
1 # Set up a virtual display to render the Lunar Lander environment.
----> 2 Display(visible=0, size=(840, 480)).start();
4 # Set the random seed for TensorFlow
5 tf.random.set_seed(utils.SEED)

File c:\Users\Erin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvirtualdisplay\display.py:54, in Display.init(self, backend, visible, size, color_depth, bgcolor, use_xauth, retries, extra_args, manage_global_env, **kwargs)
51 if not cls:
52 raise ValueError("unknown backend: s" self._backend)
—> 54 self._obj = cls(
55 size=size,
56 color_depth=color_depth,
57 bgcolor=bgcolor,
58 retries=retries,
59 use_xauth=use_xauth,
60 # check_startup=check_startup,
61 extra_args=extra_args,
62 manage_global_env=manage_global_env,
63 **kwargs
64 )

File c:\Users\Erin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvirtualdisplay\xvfb.py:44, in XvfbDisplay.init(self, size, color_depth, bgcolor, use_xauth, fbdir, dpi, retries, extra_args, manage_global_env)
41 self._fbdir = fbdir
42 self._dpi = dpi
—> 44 AbstractDisplay.init(
45 self,
46 PROGRAM,
47 use_xauth=use_xauth,
48 retries=retries,
49 extra_args=extra_args,
50 manage_global_env=manage_global_env,
51 )

File c:\Users\Erin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvirtualdisplay\abstractdisplay.py:85, in AbstractDisplay.init(self, program, use_xauth, retries, extra_args, manage_global_env)
82 self._pipe_wfd = None
83 self._retries_current = 0
—> 85 helptext = get_helptext(program)
86 self._has_displayfd = “-displayfd” in helptext
87 if not self._has_displayfd:

File c:\Users\Erin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvirtualdisplay\util.py:13, in get_helptext(program)
6 cmd = [program, “-help”]
8 # py3.7+
9 # p = subprocess.run(cmd, capture_output=True)
10 # stderr = p.stderr
11
12 # py3.6 also
—> 13 p = subprocess.Popen(
14 cmd,
15 stdout=subprocess.PIPE,
16 stderr=subprocess.PIPE,
17 shell=False,
18 )
19 _, stderr = p.communicate()
21 helptext = stderr.decode(“utf-8”, “ignore”)

File c:\Users\Erin\AppData\Local\Programs\Python\Python39\lib\subprocess.py:951, in Popen.init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask)
947 if self.text_mode:
948 self.stderr = io.TextIOWrapper(self.stderr,
949 encoding=encoding, errors=errors)
→ 951 self._execute_child(args, executable, preexec_fn, close_fds,
952 pass_fds, cwd, env,
953 startupinfo, creationflags, shell,
954 p2cread, p2cwrite,
955 c2pread, c2pwrite,
956 errread, errwrite,
957 restore_signals,
958 gid, gids, uid, umask,
959 start_new_session)
960 except:
961 # Cleanup if the child failed starting.
962 for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File c:\Users\Erin\AppData\Local\Programs\Python\Python39\lib\subprocess.py:1420, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session)
1418 # Start the process
1419 try:
→ 1420 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1421 # no special security
1422 None, None,
1423 int(not close_fds),
1424 creationflags,
1425 env,
1426 cwd,
1427 startupinfo)
1428 finally:
1429 # Child is launched. Close the parent’s copy of those pipe
1430 # handles that only the child should have open. You need
(…)
1433 # pipe will not close when the child process exits and the
1434 # ReadFile will hang.
1435 self._close_pipe_fds(p2cread, p2cwrite,
1436 c2pread, c2pwrite,
1437 errread, errwrite)

FileNotFoundError: [WinError 2] The system cannot find the file specified

Hi @sjerin,

I will take a look at it later. The lab was tested in a linux environment, and apparently you were running it on a Windows.

By the way, @sjerin, if you think you have installed all necessary files and packages, there might be something unique to Linux that does not exist on Windows. You might look into that direction, and start searching the name of the package of the function Display. Let me know if you have any updates.

Cheers,
Raymond

Seems like incompatible versions of some of the packages or Python itself.

Hi @sjerin,

I found this. If you want to run that line of code successfully, you probably will need a linux environment. What will happen if you skip that line?

Raymond