Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting rid of chromedirver console window with pyinstaller

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:

enter image description here

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?

like image 258
AhmedWas Avatar asked Dec 30 '25 03:12

AhmedWas


1 Answers

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)
like image 55
AhmedWas Avatar answered Jan 01 '26 18:01

AhmedWas