<tfoot id='au9AL'></tfoot>
    1. <i id='au9AL'><tr id='au9AL'><dt id='au9AL'><q id='au9AL'><span id='au9AL'><b id='au9AL'><form id='au9AL'><ins id='au9AL'></ins><ul id='au9AL'></ul><sub id='au9AL'></sub></form><legend id='au9AL'></legend><bdo id='au9AL'><pre id='au9AL'><center id='au9AL'></center></pre></bdo></b><th id='au9AL'></th></span></q></dt></tr></i><div id='au9AL'><tfoot id='au9AL'></tfoot><dl id='au9AL'><fieldset id='au9AL'></fieldset></dl></div>
    2. <legend id='au9AL'><style id='au9AL'><dir id='au9AL'><q id='au9AL'></q></dir></style></legend>
        <bdo id='au9AL'></bdo><ul id='au9AL'></ul>

    3. <small id='au9AL'></small><noframes id='au9AL'>

      1. 子进程 python filenotfounderror: [winerror 2]

        时间:2023-09-03
          <tbody id='0yOx2'></tbody>

          <small id='0yOx2'></small><noframes id='0yOx2'>

        1. <tfoot id='0yOx2'></tfoot>

              <legend id='0yOx2'><style id='0yOx2'><dir id='0yOx2'><q id='0yOx2'></q></dir></style></legend>
              <i id='0yOx2'><tr id='0yOx2'><dt id='0yOx2'><q id='0yOx2'><span id='0yOx2'><b id='0yOx2'><form id='0yOx2'><ins id='0yOx2'></ins><ul id='0yOx2'></ul><sub id='0yOx2'></sub></form><legend id='0yOx2'></legend><bdo id='0yOx2'><pre id='0yOx2'><center id='0yOx2'></center></pre></bdo></b><th id='0yOx2'></th></span></q></dt></tr></i><div id='0yOx2'><tfoot id='0yOx2'></tfoot><dl id='0yOx2'><fieldset id='0yOx2'></fieldset></dl></div>
              • <bdo id='0yOx2'></bdo><ul id='0yOx2'></ul>

                  本文介绍了子进程 python filenotfounderror: [winerror 2]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我一直在使用 Jupyter Notebook 学习 kaggle 的主成分分析),但是当我运行这段代码时

                  I've been using Jupyter Notebook to learn Principal Component Analysis from kaggle), but when I run this code

                       from subprocess import check_output
                       print(check_output(["ls", "../input"]).decode("utf8"))
                  

                  下面出现错误

                  FileNotFoundError Traceback (most recent call last)
                  <ipython-input-3-de0e39ca3ab8> in <module>()
                        1 from subprocess import check_output
                  ----> 2 print(check_output(["ls", "C:/Users/wanglei/Documents/input"]).decode("utf8"))
                  
                  D:Anaconda3libsubprocess.py in check_output(timeout, *popenargs, **kwargs)
                      624 
                      625     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
                  --> 626                **kwargs).stdout
                      627 
                      628 
                  
                  D:Anaconda3libsubprocess.py in run(input, timeout, check, *popenargs, **kwargs)
                      691         kwargs['stdin'] = PIPE
                      692 
                  --> 693     with Popen(*popenargs, **kwargs) as process:
                      694         try:
                      695             stdout, stderr = process.communicate(input, timeout=timeout)
                  
                  D:Anaconda3libsubprocess.py in __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)
                      945                                 c2pread, c2pwrite,
                      946                                 errread, errwrite,
                  --> 947                                 restore_signals, start_new_session)
                      948         except:
                      949             # Cleanup if the child failed starting.
                  
                  D:Anaconda3libsubprocess.py in _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)
                     1222                                          env,
                     1223                                          cwd,
                  -> 1224                                          startupinfo)
                     1225             finally:
                     1226                 # Child is launched. Close the parent's copy of those pipe
                  

                  路径是正确的,似乎所有来自子进程的调用都会同样失败.

                  The path is correct, and it seems that all the call from subprocess will fail similarly.

                  有人知道为什么会这样吗?

                  Does anyone have any idea why this is happening?

                  推荐答案

                  此代码运行 ls 命令,在所有 POSIX 上都可用-符合系统.

                  您使用的是 Microsoft Windows.默认情况下,Microsoft Windows 不符合 POSIX.例如,没有 ls 二进制文件.因此,子进程找不到文件ls,从而发出FileNotFoundError.

                  You are using Microsoft Windows. Microsoft Windows does not conform to POSIX by default. For instance, there is no ls binary. Therefore, subprocess cannot find the file ls, and thus emits a FileNotFoundError.

                  您可以在 Windows 上安装 Microsoft 的 Bash,它会给你 ls.

                  You can install Microsoft's Bash on Windows, which will give you ls.

                  然而,列出目录的pythonic和更便携的方法不是首先使用子进程,而是内置的os.listdir:

                  However, the pythonic and more portable way to list a directory is not to use subprocess in the first place, but the built-in os.listdir:

                  import os
                  print(os.listdir('../input'))
                  

                  这篇关于子进程 python filenotfounderror: [winerror 2]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:子进程中的`shell = True`中的`shell`是否意味着`bash`? 下一篇:在 Heroku dyno 上运行多个进程是否可行?

                  相关文章

                1. <i id='0S85C'><tr id='0S85C'><dt id='0S85C'><q id='0S85C'><span id='0S85C'><b id='0S85C'><form id='0S85C'><ins id='0S85C'></ins><ul id='0S85C'></ul><sub id='0S85C'></sub></form><legend id='0S85C'></legend><bdo id='0S85C'><pre id='0S85C'><center id='0S85C'></center></pre></bdo></b><th id='0S85C'></th></span></q></dt></tr></i><div id='0S85C'><tfoot id='0S85C'></tfoot><dl id='0S85C'><fieldset id='0S85C'></fieldset></dl></div>
                  <tfoot id='0S85C'></tfoot>
                2. <legend id='0S85C'><style id='0S85C'><dir id='0S85C'><q id='0S85C'></q></dir></style></legend>
                    <bdo id='0S85C'></bdo><ul id='0S85C'></ul>

                      <small id='0S85C'></small><noframes id='0S85C'>