subprocess.check_output('dir',shell = True)生成FileNotFoundError

时间:2017-06-16 22:58:08

标签: python python-3.x

我正在尝试运行一个我已成功在其他几台机器上运行的脚本,并且出于某种原因,当我在这台特定的机器上运行它时,我不断收到此错误。这是Windows 10,但我的另一个,也不确定是什么问题。任何帮助将不胜感激。

代码:

import subprocess

subprocess.check_output('dir',shell=True)

完整的错误消息是:

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    subprocess.check_output('dir',shell=True)
  File "C:\Program Files\Python36\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "C:\Program Files\Python36\lib\subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Program Files\Python36\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files\Python36\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

谢谢!

0 个答案:

没有答案
相关问题