Getting rid of chromedirver console window with pyinstaller

倾然丶 夕夏残阳落幕 提交于 2019-12-23 01:06:07

问题


I'm using chromedriver in headless mode. I compile the script using pyinstaller as one exe file. Everything works fine, except that I get the following console window whenever I open a chrome page:

I've tried the options --windowed alone, --noconsole alone, --windowed and --noconsole together but I still get this window.

How can I get rid of it?


回答1:


I was able to find the following answer and it's working perfectly for me:

To avoid getting console windows for chromedriver, open the file

Python\Lib\site-packages\selenium\webdriver\common\service.py

and change

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

To:

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


来源:https://stackoverflow.com/questions/52643556/getting-rid-of-chromedirver-console-window-with-pyinstaller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!