WebDriverException:消息:未知错误:C:\..处没有chrome二进制文件/Chrome/Appli



这里有点像Python新手。。。

Windows 7 x64和Python 3.7

我已经安装了Selenium和Chrome网络驱动程序。我正在使用:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'
driver = webdriver.Chrome(chrome_options=options, executable_path='C:/python/chromedriver.exe')
driver.get('http://google.com/')

我得到:

pythonpython.exe C:/py/defectURLS/app.py
C:/py/defectURLS/app.py:6: DeprecationWarning: use options instead of chrome_options
driver = webdriver.Chrome(chrome_options=options, executable_path='C:/python/chromedriver.exe')
Traceback (most recent call last):
File "C:/py/defectURLS/app.py", line 6, in <module>
driver = webdriver.Chrome(chrome_options=options, executable_path='C:/python/chromedriver.exe')
File "C:pythonlibsite-packagesselenium-3.141.0-py3.7.eggseleniumwebdriverchromewebdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "C:pythonlibsite-packagesselenium-3.141.0-py3.7.eggseleniumwebdriverremotewebdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:pythonlibsite-packagesselenium-3.141.0-py3.7.eggseleniumwebdriverremotewebdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:pythonlibsite-packagesselenium-3.141.0-py3.7.eggseleniumwebdriverremotewebdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:pythonlibsite-packagesselenium-3.141.0-py3.7.eggseleniumwebdriverremoteerrorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at C:/Program Files (x86)/Google/Chrome/Application/chrome.exe
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 6.1.7601 SP1 x86_64)

现在,我很确定确凿的证据是:

selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at C:/Program Files (x86)/Google/Chrome/Application/chrome.exe
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 6.1.7601 SP1 x86_64)

这向我表明,Selenium可以找到合适的网络驱动程序,因为它能够报告回网络驱动程序的版本。该错误似乎表明chrome二进制文件没有位于给定位置。但我完全确定这就是Chrome.exe的所在地。我可以从该路径直接启动chrome.exe,没有任何问题。

如果能及时发现问题,我将不胜感激。

此错误消息。。。

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

意味着ChromeDriver无法定位chrome二进制文件chrome.exe

您需要考虑以下几个事实:

  • 您可能正在使用Selenium Python Client v3.14.1Serenium Python客户端v3.141.0,并且chrome_options现在已被弃用。尽管chrome_options仍然有效,但您需要使用options
  • 密钥executable_path必须由支持,如下所示:
    • r'C:pythonchromedriver.exe'
    • "C:/python/chromedriver.exe"
    • "C:\python\chromedriver.exe"

最新更新