首页 文章

Selenium:WebDriverException:Chrome无法启动:由于google-chrome不再运行而崩溃,因此ChromeDriver假设Chrome已崩溃

提问于
浏览
3

我知道这个问题有几个答案,但到目前为止我没有任何帮助,所以我发布了一个新问题 .

最近我换了电脑,从那时起我不能用硒发射铬 . 我也试过firefox但浏览器只是没有lanch .

from selenium import webdriver

d = webdriver.Chrome('/home/PycharmProjects/chromedriver')

d.get('https://www.google.nl/')

我收到以下错误:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /opt/google/chrome/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.43.600233, platform=Linux 4.15.0-38-generic x86_64)

我安装了最新的chrome版本和chromedriver

编辑:尝试@ b0sss解决方案后,我收到以下错误 .

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
  (chrome not reachable)
  (The process started from chrome location /opt/google/chrome/google-chrome is no longer running, so chromedriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d),platform=Linux 4.15.0-38-generic x86_64)

2 回答

  • 1

    此错误消息...

    selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
      (unknown error: DevToolsActivePort file doesn't exist)
      (The process started from chrome location /opt/google/chrome/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
    

    ...暗示 ChromeDriver 无法发起/产生新的 WebBrowserChrome Browser 会话 .

    您的主要问题是 Chrome 浏览器未安装在系统中的 default location .

    服务器即ChromeDriver希望您将Chrome安装在每个系统的默认位置,如下图所示:

    Chrome_binary_expected_location

    1对于Linux系统,ChromeDriver希望 /usr/bin/google-chrome 成为实际Chrome二进制文件的符号链接 .


    解决方案

    如果您在非标准位置使用 Chrome 可执行文件,则必须覆盖Chrome二进制位置 . 如下:

    Chrome executable in a non-standard location

  • 1

    尝试下载HERE并使用最新的Chrome驱动程序版本 .

    https://sites.google.com/a/chromium.org/chromedriver/downloads

    编辑:

    试试这个:

    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-dev-shm-usage')
    d = webdriver.Chrome('/home/PycharmProjects/chromedriver',chrome_options=chrome_options)
    d.get('https://www.google.nl/')
    

相关问题