I try 2 options with pyinstaller one with console and one without.
I am using Windows 10, Python 3.5.4, Windows Chrome Driver 2.33 and Selnium 3.6.0 and Pyinstaller 3.3.
The one without console fails:
Here is the code for Test.py
#!python3
from selenium import webdriver
# Chrome Proxy options and disable the Yellow Bar about Chrome being controlled by Automated Software.
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--disable-logging")
chrome_options.add_argument("--disable-notifications")
chrome_options.add_argument("--disable-default-apps")
chrome_options.add_argument("--disable-extensions")
# load google.com with the proxy settings and a logging path to a file
driver = webdriver.Chrome(r"D:Seleniumchromedriver_win32chromedriver.exe", chrome_options=chrome_options)
# maximise window
driver.maximize_window()
driver.get("https://www.google.com/mail")
Here are the pyinstaller commands with the exact same code:
- With console window aka works:
pyinstaller -F -i favicon.ico Test.py
- Without the console Window fails
pyinstaller -F --noconsole -i favicon.ico Test.py
I get this error:
*"Failed to execute script error"*
I am not sure why.
Thanks
Thanks for your reply I looked in:
C:UsersestuserAppDataLocalProgramsPythonPython35Libsite-packagesseleniumwebdriverchromeservice.py
There was nothing for subprocess here.
I also checked:
C:UsersestuerAppDataLocalProgramsPythonPython35Libsite-packagesseleniumwebdrivercommonservice.py
On line 70 I added in the entry for stdin=self.log_file as it was missing
try:
cmd = [self.path]
cmd.extend(self.command_line_args())
self.process = subprocess.Popen(cmd, env=self.env,
close_fds=platform.system() != 'Windows',
stdin=self.log_file, stdout=self.log_file, stderr=self.log_file)
Recreated with pyinstaller:
pyinstaller -F --noconsole -i favicon.ico Test.py
This created the exe however now the console window appeared....
Python program with selenium(webdriver) Don't Work as single and noconsole exe file (pyinstaller)
See Question&Answers more detail:
os