美文网首页
用Pyinstaller打包selenium的去掉chromed

用Pyinstaller打包selenium的去掉chromed

作者: WMSmile | 来源:发表于2020-09-02 11:35 被阅读0次

用Pyinstaller打包selenium的去掉chromedriver黑框

解决方案就是修改selenium包中的service.py(selenium->webdriver->common->service.py)源码。

def start(self):
        """
        Starts the Service.

        :Exceptions:
         - WebDriverException : Raised either when it can't start the service
           or when it can't connect to the service
        """
        try:
            cmd = [self.path]
            cmd.extend(self.command_line_args())
            self.process = subprocess.Popen(cmd, env=self.env,
                                            close_fds=platform.system() != 'Windows',
                                            stdout=self.log_file,
                                            stderr=self.log_file,
                                            stdin=PIPE)
        except TypeError:
            raise

添加 creationflags=134217728

self.process = subprocess.Popen(cmd, env=self.env,
                                            close_fds=platform.system() != 'Windows',
                                            stdout=self.log_file,
                                            stderr=self.log_file,
                                            stdin=PIPE,
                                            creationflags=134217728)

保存打包,黑框消失了

相关文章

网友评论

      本文标题:用Pyinstaller打包selenium的去掉chromed

      本文链接:https://www.haomeiwen.com/subject/txbrrktx.html