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

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

    Traceback (most recent call last):
      File "D:PythonPython36-32libsite-packagesselenium-3.4.3-py3.6.eggseleniumwebdrivercommonservice.py", line 74, in start
        stdout=self.log_file, stderr=self.log_file)
      File "D:PythonPython36-32libsubprocess.py", line 707, in __init__
        restore_signals, start_new_session)
      File "D:PythonPython36-32libsubprocess.py", line 990, 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 参数。

  • 相关阅读:
    Qt简介以及如何配置Qt使用VS2010进行开发
    QT里重定向另外一个控制台程序的输出
    windows下制作PHP扩展
    20款Notepad++插件下载和介绍
    音频编码协议介绍
    用 PHP 读取文件的正确方法
    QT进程间通信
    关于YUV色彩空间
    解析xml 四种
    System.getProperty
  • 原文地址:https://www.cnblogs.com/jqpy1994/p/10135924.html
Copyright © 2011-2022 走看看