zoukankan      html  css  js  c++  java
  • FileNotFoundError: [WinError 2] 系统找不到指定的文件。 解决方案

    用Idle运行Python脚本的时候发现如下错误:

    Traceback (most recent call last):
    File "C:UsersDangKaiDesktoppythonUI-unittest-seleniumvenvlibsite-packagesseleniumwebdrivercommonservice.py", line 76, in start
    stdin=PIPE)
    File "D:SoftwarePython37libsubprocess.py", line 756, in init
    restore_signals, start_new_session)
    File "D:SoftwarePython37libsubprocess.py", line 1155, in _execute_child
    startupinfo)
    FileNotFoundError: [WinError 2] 系统找不到指定的文件。

    后来在stackoverflow上找到如下解决办法:

    In Windows , to use echo in subprocess, you would need to use shell=True . This is because echo is not a separate executable, but rather a built-in command for the windows command line. Example - 在windows 在子进程中使用echo,需要设置 shell =True,因为 echo 不是单独的命令,而是window CMD 内置的命令

    process1 = subprocess.Popen(command1,stdout=subprocess.PIPE,shell=True)
    Also, please do note, you should only use shell=True when absolutely necessary (as in this case , to use echo in windows in subprocess).

    并且,需要注意,只有在绝对需要的情况下才使用shell=True

    找到 subprocess.py脚本,将对应行加上shell=true 参数

  • 相关阅读:
    C++笔记(2018/2/6)
    2017级面向对象程序设计寒假作业1
    谁是你的潜在朋友
    A1095 Cars on Campus (30)(30 分)
    A1083 List Grades (25)(25 分)
    A1075 PAT Judge (25)(25 分)
    A1012 The Best Rank (25)(25 分)
    1009 说反话 (20)(20 分)
    A1055 The World's Richest(25 分)
    A1025 PAT Ranking (25)(25 分)
  • 原文地址:https://www.cnblogs.com/dangkai/p/11372220.html
Copyright © 2011-2022 走看看