Assignment Lunar Lander Display FileNotFoundError: [WinError 2] The system cannot find the file specified

I’m trying to run the Lunar Lander on my own device and I get the following response in Cell 2, aka

Set up a virtual display to render the Lunar Lander environment.

Display(visible=0, size=(840, 480)).start();

Set the random seed for TensorFlow

tf.random.set_seed(utils.SEED)


FileNotFoundError Traceback (most recent call last)
Cell In[2], 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 ~\AppData\Roaming\Python\Python310\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 ~\AppData\Roaming\Python\Python310\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 ~\AppData\Roaming\Python\Python310\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 ~\AppData\Roaming\Python\Python310\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:\ProgramData\miniconda3\lib\subprocess.py:971, 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, pipesize)
967 if self.text_mode:
968 self.stderr = io.TextIOWrapper(self.stderr,
969 encoding=encoding, errors=errors)
→ 971 self._execute_child(args, executable, preexec_fn, close_fds,
972 pass_fds, cwd, env,
973 startupinfo, creationflags, shell,
974 p2cread, p2cwrite,
975 c2pread, c2pwrite,
976 errread, errwrite,
977 restore_signals,
978 gid, gids, uid, umask,
979 start_new_session)
980 except:
981 # Cleanup if the child failed starting.
982 for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File C:\ProgramData\miniconda3\lib\subprocess.py:1440, 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)
1438 # Start the process
1439 try:
→ 1440 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1441 # no special security
1442 None, None,
1443 int(not close_fds),
1444 creationflags,
1445 env,
1446 cwd,
1447 startupinfo)
1448 finally:
1449 # Child is launched. Close the parent’s copy of those pipe
1450 # handles that only the child should have open. You need
(…)
1453 # pipe will not close when the child process exits and the
1454 # ReadFile will hang.
1455 self._close_pipe_fds(p2cread, p2cwrite,
1456 c2pread, c2pwrite,
1457 errread, errwrite)

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

And I don’t understand what file it’s not finding.

1 Like

Me too, answer needed

The only reason I can find is that the codes are prepared for linux, so pyvirtualdisplay is not a library available for windows.

Hello,
This is my first post. Although I have finished entire Machine learning specialization yesterday. I’m getting the same error too when m doing this on my windows(jupyter notebook)

I am copy pasting the error below…

WARNING:tensorflow:From C:\Users\Mancy\anaconda3\Lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.


FileNotFoundError Traceback (most recent call last)
Cell In[1], line 18
14 from tensorflow.keras.optimizers import Adam
17 # Set up a virtual display to render the Lunar Lander environment.
—> 18 Display(visible=0, size=(840, 480)).start();
20 # Set the random seed for TensorFlow
21 tf.random.set_seed(utils.SEED)

File ~\anaconda3\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 ~\anaconda3\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 ~\anaconda3\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 ~\anaconda3\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 ~\anaconda3\Lib\subprocess.py:1026, 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, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
→ 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~\anaconda3\Lib\subprocess.py:1538, 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, unused_process_group)
1536 # Start the process
1537 try:
→ 1538 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1539 # no special security
1540 None, None,
1541 int(not close_fds),
1542 creationflags,
1543 env,
1544 cwd,
1545 startupinfo)
1546 finally:
1547 # Child is launched. Close the parent’s copy of those pipe
1548 # handles that only the child should have open. You need
(…)
1551 # pipe will not close when the child process exits and the
1552 # ReadFile will hang.
1553 self._close_pipe_fds(p2cread, p2cwrite,
1554 c2pread, c2pwrite,
1555 errread, errwrite)

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