我在嘗試運行我的代碼時收到了這個錯誤,讓我知道我能做什么。如果需要,我會在這里發布完整的代碼。
Traceback (most recent call last):
File "C:\Users\hp\Desktop\FB\GUI.py", line 104, in <module>
main()
File "C:\Users\hp\Desktop\FB\GUI.py", line 65, in main
driver = webdriver.Chrome(options=options)
File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-
packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 424, in execute
self.error_handler.check_response(response)
File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.19042 x86_64)
uj5u.com熱心網友回復:
你需要安裝一個 chrome 驅動程式并告訴 selenium 在哪里可以找到它。通過:
- 更新你的路徑
- 實體化新驅動程式時使用 executable_path
然后安裝 chrome 并告訴 chrome 驅動程式在哪里可以找到它。
uj5u.com熱心網友回復:
該訊息表明 Chrome 驅動程式未安裝或 Python 代碼未找到。
檢查以下鏈接以設定 Chrome 驅動程式:
https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver
最好的方法是從以下鏈接下載二進制檔案:
https://sites.google.com/a/chromium.org/chromedriver/
完成后,您可以識別本地目錄中存在的驅動程式路徑,如下所示:
from selenium import webdriver from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()
uj5u.com熱心網友回復:
您沒有為瀏覽器安裝驅動程式,或者python代碼找不到它。在 Selenium 官方網站上,您可以找到安裝相應驅動程式的詳細說明:https : //www.selenium.dev/documentation/webdriver/getting_started/install_drivers/。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/381781.html
