Selenium don't work after exporting to EXE in windowed mode in pyinstaller

后端 未结 2 1576

I am making an PyQt4 application where I need to use selenium. Everything works fine while development but when I exported to single file EXE, by pyinstalle

相关标签:
2条回答
  • 2021-01-17 04:15

    I found out that pyinstaller doesn't create a copy of chromedriver.exe in the dist folder. Copying chromedriver.exe file to there solved the problem for me.

    0 讨论(0)
  • 2021-01-17 04:20

    After a lot of research, I found a solution for the above problem.

    What you just need to do is edit the file:
    C:\Python34\Lib\site-packages\selenium\webdriver\common\service.py

    Change the following line:

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

    to:

    self.process = subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=False, creationflags=0x08000000)
    

    This will work even while development and also after deploying to EXE.

    Might be a selenium bug.

    0 讨论(0)
提交回复
热议问题