当前位置: 首页 > 知识库问答 >
问题:

WebDriverException:消息:未知错误:Chrome启动失败:退出Chromedriver 2.26 Selenium异常错误

谷梁嘉运
2023-03-14

我正试图在Ubuntu中设置chrome webdriver。我已经做了

pip install selenium

我可以做到

from selenium import webdriver

为了安装chrome webdriver,我尝试了很多东西。例如,我累了一个回答从不能用chrome驱动在这里为硒,我试了

    null
from selenium import webdriver
driver = webdriver.Chrome()

然而,在第二行中,我得到了一个错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/../.local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/home/../.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/../.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/../.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/../.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac),platform=Linux 4.15.0-109-generic x86_64)

有人能帮我吗?

共有1个答案

邓星光
2023-03-14

使用webdriver-manager

WebDriver-Manager

以下3行应该为你做这项工作:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install()) 
 类似资料: