简体   繁体   English

OSError: [WinError 193] 在 Python 中通过 Selenium ChromeDriver 和 Chrome 自动化时,%1 不是有效的 Win32 应用程序

[英]OSError: [WinError 193] %1 is not a valid Win32 application while automating through Selenium ChromeDriver and Chrome in Python

Code block:代码块:

import time
from selenium import webdriver

browser = webdriver.Chrome('C:/Users/Cypher/Downloads/chromedriver_win32.zip')
browser.maximize_window()
browser.get('https://www.google.com/gmail/')
email_field = browser.find_element_by_id('identifierId')
email_field.clear()
email_field.send_keys('My mail')
email_next_button = browser.find_element_by_id('identifierNext')
email_next_button.click()
time.sleep(1)
password_field = browser.find_element_by_name('password')
password_field.clear()
password_field.send_keys('My password')
password_next_button = browser.find_element_by_id('passwordNext')
password_next_button.click()
time.sleep(100)
browser.quit()

Error:错误:

Traceback (most recent call last):
  File "C:/Users/Cypher/PycharmProjects/untitled5/login_gmail.py", line 4, in <module>
    driver = webdriver.Chrome('C:/Users/Cypher/Downloads/chromedriver_win32.zip')
  File "C:\Users\Cypher\PycharmProjects\untitled5\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\Cypher\PycharmProjects\untitled5\venv\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\Cypher\Miniconda3\lib\subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Cypher\Miniconda3\lib\subprocess.py", line 1155, in _execute_child
    startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application

Just extract the chromedriver you have downloaded... chromedriver_win32.zip make sure you have the chromedriver.exe file in the downloads...只需提取您下载的 chromedriver... chromedriver_win32.zip确保您在下载中有chromedriver.exe文件...

browser = webdriver.Chrome('C:/Users/Cypher/Downloads/chromedriver.exe')

Hope this helps you!希望这对你有帮助!

This error message...这个错误信息...

OSError: [WinError 193] %1 is not a valid Win32 application

...implies that the argument which you have passed to initialize Chrome was not in the valid format. ...暗示您传递给初始化Chrome参数不是有效格式。

You need to consider a couple of facts as follows:您需要考虑以下几个事实:

  • When you simply pass the absolute location of the ChromeDriver by default it is considered as the Value for the argument executable_path which accepts a value of an executable binary默认情况下,当您简单地传递ChromeDriver绝对位置时,它被视为参数executable_path,该参数接受可执行二进制文件的值
  • As you are on Windows OS you need to extract the chromedriver.exe from chromedriver_win32.zip and place it anywhere within your system.当你使用Windows操作系统,你需要提取chromedriver_win32.zipchromedriver.exe和任何地方放置在您的系统中。
  • Next you need to pass the absolute location of the chromedriver.exe along with the argument executable_path .接下来,您需要传递chromedriver.exe绝对位置以及参数executable_path
  • The argument executable_path must be supported with a Value as either of the following:参数executable_path必须支持以下任一

    • r'C:\\path\\to\\chromedriver.exe'
    • "C:/python/chromedriver.exe"
    • "C:\\\\python\\\\chromedriver.exe"
  • The working line of code will be:工作代码行将是:

     from selenium import webdriver browser = webdriver.Chrome(executable_path=r'C:\\path\\to\\chromedriver.exe')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OSError: [WinError 193] %1 is not a valid Win32 application error using GeckoDriver and Firefox through Selenium and Python on Windows - OSError: [WinError 193] %1 is not a valid Win32 application error using GeckoDriver and Firefox through Selenium and Python on Windows OSError: [WinError 193] %1 不是 Python 中的有效 Win32 应用程序 - OSError: [WinError 193] %1 is not a valid Win32 application in python OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - python - OSError: [WinError 193] %1 is not a valid Win32 application - python Python 错误:OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - Python error: OSError: [WinError 193] %1 is not a valid Win32 application OSError: [WinError 193] %1 不是有效的 Win32 应用程序 Python - OSError: [WinError 193] %1 is not a valid Win32 application Python OSError: [WinError 193] %1 在使用 CTypes 读取 python 中的自定义 DLL 时不是有效的 Win32 应用程序 - OSError: [WinError 193] %1 is not a valid Win32 application while reading custom DLL in python with CTypes Python Selenium 测试:[WinError 193] %1 不是有效的 Win32 应用程序 - Python Selenium test: [WinError 193] %1 is not a valid Win32 application OSError: [WinError 193] %1 不是有效的 Win32 应用程序 (Pandas) - OSError: [WinError 193] %1 is not a valid Win32 application (Pandas) OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - OSError: [WinError 193] %1 is not a valid Win32 application OSError: [WinError 193] %1 不是有效的 Win32 应用程序 (LibTiff) - OSError: [WinError 193] %1 is not a valid Win32 application (LibTiff)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM