Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Weird failure in Selenium
#1
Hi ,

I'm trying to run this script

#!/usr/bin/env python3
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import time
 
# Configure Chrome options (optional)
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")  # Open browser maximized
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0")
options.add_argument("--headless")  # Run in background (no GUI)
options.add_experimental_option("detach", True)
 
drv = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=options)
But when I run it on my machine it fails

Error:
C:\tmp>python e.py Traceback (most recent call last): File "C:\tmp\e.py", line 22, in <module> drv = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__ super().__init__( File "C:\Python311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 53, in __init__ self.service.start() File "C:\Python311\Lib\site-packages\selenium\webdriver\common\service.py", line 105, in start self._start_process(self._path) File "C:\Python311\Lib\site-packages\selenium\webdriver\common\service.py", line 206, in _start_process self.process = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\subprocess.py", line 1022, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Python311\Lib\subprocess.py", line 1491, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [WinError 193] %1 is not a valid Win32 application
Attempt to run this

python -c "import sys; print(sys.version);"
produces this:

Output:
3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
What I'm supposed to do to have it fixed? This machine has both Chrome 141.0.7390.54 (Official Build) (64-bit) and FF 140.3.0esr (32-bit)
Reply
#2
Are you using a 64 bit machine?

Quote:The OSError: [WinError 193] %1 is not a valid Win32 application error typically indicates a mismatch in architecture (32-bit vs. 64-bit) or a conflict in the execution environment, particularly when dealing with Python or other applications that rely on external libraries (DLLs).
see: OSError for full details, and how to fix.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SSL Handshake Failure with Python 3.11 and 3.12 Samanth_m 0 3,395 Nov-15-2024, 03:35 PM
Last Post: Samanth_m
  Failure to run source command middlestudent 2 1,984 Sep-22-2023, 01:21 PM
Last Post: buran
  Dickey Fuller failure Led_Zeppelin 4 5,265 Sep-15-2022, 09:07 PM
Last Post: Led_Zeppelin
  Assert failure jtcostel 1 2,730 Sep-03-2021, 05:28 PM
Last Post: buran
  xml decoding failure(bs4) roughstroke 1 3,842 May-09-2020, 04:37 PM
Last Post: snippsat
  SCIKIT learn failure in mac Perja11 1 4,161 Nov-30-2019, 06:44 PM
Last Post: snippsat
  failure to find modules justus123 2 7,330 Dec-14-2018, 04:28 PM
Last Post: nilamo
  LIB install failure Able98 2 5,600 Jun-07-2017, 06:41 PM
Last Post: Able98

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020