Python Selenium Edge驱动报错OSError: [WinError 193] 求助
Edge自动化报错OSError: [WinError 193] 解决方案求助
我是Python和Selenium新手,此前在PyCharm中编写的Edge浏览器自动化代码正常运行数日,如今在执行driver = webdriver.Edge(options=options)时出现OSError: [WinError 193] %1 is not a valid Win32 application错误。已尝试重装Python、PyCharm,切换32位Python版本,但均未解决问题。以下是出错的代码片段及完整报错信息,恳请提供解决方案:
代码片段
from selenium import webdriver from selenium.webdriver.edge.options import Options # from selenium.webdriver.common.keys import Key from time import sleep from selenium.webdriver.support.select import Select options = Options() options = webdriver.EdgeOptions() options.add_experimental_option("detach", True) options.add_argument(r"user-data-dir=C:\Users\reals\AppData\Local\Microsoft\Edge\User Data") options.add_argument("profile-directory=Profile 1") options.binary_location = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" options.add_extension(r"C:\Users\reals\Downloads\Compressed\ABS-20230126T194006Z-001\ABS.crx") # create a new Edge driver instance driver = webdriver.Edge(options=options)
完整报错信息
Traceback (most recent call last): File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 195, in _start_process self.process = subprocess.Popen( File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 88, in start self._start_process(self.path) File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 209, in _start_process raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: 'msedgedriver' executable needs to be in PATH. Please download from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\reals\PycharmProjects\pythonProject1\jade.py", line 17, in <module> driver = webdriver.Edge(options=options) File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 73, in __init__ super().__init__( File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 101, in __init__ self.service.start() File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 100, in start self._start_process(path) File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 195, in _start_process self.process = subprocess.Popen( File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\reals\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, OSError: [WinError 193] %1 is not a valid Win32 application
内容的提问来源于stack exchange,提问作者FRAMED KING
相关产品推荐
相关产品推荐

