1

Python 3.2 がインストールされており、サブプロセス モジュールを使用しようとしていますが、エラーが発生し続けます。

私が使用しているコードは次のとおりです。

import subprocess
subprocess.check_output(["echo", "Hello World!"])
subprocess.check_output("exit 1", shell=True)

次のエラーが発生し続けますsubprocess.check_output(["echo", "Hello World!"])

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    subprocess.check_output(["echo", "Hello World!"])
  File "C:\Python32\lib\subprocess.py", line 514, in check_output
    process = Popen(*popenargs, stdout=PIPE, **kwargs)
  File "C:\Python32\lib\subprocess.py", line 744, in __init__
    restore_signals, start_new_session)
  File "C:\Python32\lib\subprocess.py", line 977, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

行についてはsubprocess.check_output("exit 1", shell=True)、次のエラーが発生します。

Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    subprocess.check_output("exit 1", shell=True)
  File "C:\Python32\lib\subprocess.py", line 521, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'exit 1' returned non-zero exit status 1
4

1 に答える 1