2

I'm leanrning Andrew Ng's course which is 2022 Machine Learning Specialization.

There is a lab in the week3 of course3, in which the code shows below:

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

But I got the below error when I ran the cell in jupyter:

FileNotFoundError                         Traceback (most recent call last)
Input In [2], in <cell 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 D:\ProgramData\Anaconda3\envs\ML\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 D:\ProgramData\Anaconda3\envs\ML\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 D:\ProgramData\Anaconda3\envs\ML\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 D:\ProgramData\Anaconda3\envs\ML\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 D:\ProgramData\Anaconda3\envs\ML\lib\subprocess.py:858, 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, encoding, errors, text)
    854         if self.text_mode:
    855             self.stderr = io.TextIOWrapper(self.stderr,
    856                     encoding=encoding, errors=errors)
--> 858     self._execute_child(args, executable, preexec_fn, close_fds,
    859                         pass_fds, cwd, env,
    860                         startupinfo, creationflags, shell,
    861                         p2cread, p2cwrite,
    862                         c2pread, c2pwrite,
    863                         errread, errwrite,
    864                         restore_signals, start_new_session)
    865 except:
    866     # Cleanup if the child failed starting.
    867     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File D:\ProgramData\Anaconda3\envs\ML\lib\subprocess.py:1311, 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_start_new_session)
   1309 # Start the process
   1310 try:
-> 1311     hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
   1312                              # no special security
   1313                              None, None,
   1314                              int(not close_fds),
   1315                              creationflags,
   1316                              env,
   1317                              cwd,
   1318                              startupinfo)
   1319 finally:
   1320     # Child is launched. Close the parent's copy of those pipe
   1321     # handles that only the child should have open.  You need
   (...)
   1324     # pipe will not close when the child process exits and the
   1325     # ReadFile will hang.
   1326     self._close_pipe_fds(p2cread, p2cwrite,
   1327                          c2pread, c2pwrite,
   1328                          errread, errwrite)

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

I learned that maybe it is the value of the parameter 'shell' in 'subprocess.init()' that cause the error, but it would lead to another error after I tried switching 'shell' from False to True in the subprocess.py as well as in other functions pointed out by above error so that I dare not to modify those file.

Anyone can solve this problem? Please help me!

yishifeng
  • 21
  • 1

0 Answers0