PROBLEM
Presenting the problem and the solution together:
While developing some Selenium code, I encountered the error [WinError 193] %1 is not a valid Win32 application, which was always related to my Selenium webdriver. I quickly realized this by debugging the code, but it took me several hours to actually solve the problem.
Traceback (most recent call last):
File "path/to/navegador.py", line 49, in iniciar_navegador
navegador = webdriver.Chrome(service=servico, options=chrome_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/to/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "path/to/selenium/webdriver/chromium/webdriver.py", line 55, in __init__
self.service.start()
File "path/to/selenium/webdriver/common/service.py", line 98, in start
self._start_process(self._path)
File "path/to/selenium/webdriver/common/service.py", line 208, in _start_process
self.process = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "path/to/python/Lib/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "path/to/python/Lib/subprocess.py", line 1538, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
SOLUTION
The solution to the problem I was facing was to understand what was causing the error. I checked my driver_path and where it was installed:
driver_path = ChromeDriverManager().install()
print(f"ChromeDriver path: {driver_path}")
Then I realized that the return I was getting was not chromedriver.exe but another type of file.
- Print output:
ChromeDriver path: C:UsersUser.wdmdriverschromedriverwin64127.0.6533.72chromedriver-win32/THIRD_PARTY_NOTICES.chromedriver
So, I did the following: I went to the location where the file was installed using File Explorer, deleted the two files LICENSE.chromedriver and THIRD_PARTY_NOTICES.chromedriver, leaving only chromedriver.exe, and then ran my code again. After this, the browser opened normally, and the code worked as expected.
forest VQV is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.