【问题标题】:unknown error: chrome failed to start未知错误:chrome 无法启动
【发布时间】:2017-11-06 17:14:36
【问题描述】:

由于这个问题,我被困了好几天,似乎找不到解决方案。无论我做什么,我都无法让 chromedriver 在我的机器上工作。我已经尝试了几乎所有我能想象到的设置。列举几个:

  • Chrome 64 位,Python 64 位
  • Chrome 32 位,Python 32 位
  • Chrome 64 位,Python 32 位
  • Chrome 32 位,Python 64 位

我还尝试了不同版本的 Chrome 及其相应的 chromedriver 版本。我已经尝试过不同的 selenium 早期版本,也就是说,在前面提到的每个设置上。

对于实际情况,这是我当前的设置:

  • Windows 10 专业版 x64
  • Python 3.6.3 64 位
  • 硒 3.7.0
  • 谷歌浏览器 62.0.3202.75 64 位
  • Chromedriver 2.33

我不会发布我的代码,因为无论我使用哪个代码,它都会失败。即使是启动 chromedriver 的最简单最基本的代码也不起作用。此外,它适用于我同事的机器。因此,为了提供一些上下文,这是我尝试过的代码 sn-p 不起作用:

from selenium import webdriver

webdriver.Chrome(executable_path="bin/chromedriver.exe")

我还尝试将 chromedriver 添加到我的 PATH 并启动不带参数的 chromedriver,但这也不起作用。

我得到的错误是这个:

selenium.common.exceptions.WebDriverException: Message: unknown error: chrome failed to start
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64)

如果我使用详细/日志记录参数启动驱动程序,则会生成以下日志:

[1.979][INFO]: COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "browserName": "chrome",
         "goog:chromeOptions": {
            "args": [  ],
            "extensions": [  ]
         },
         "platformName": "any"
      },
      "firstMatch": [ {

      } ]
   },
   "desiredCapabilities": {
      "browserName": "chrome",
      "goog:chromeOptions": {
         "args": [  ],
         "extensions": [  ]
      },
      "platform": "ANY",
      "version": ""
   }
}
[1.985][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "show_welcome_page": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[1.989][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[2.004][INFO]: Cannot switch to US keyboard layout - some keys may be interpreted incorrectly
[2.004][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-browser-side-navigation --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --load-extension="C:\Users\OLIVIE~1.VER\AppData\Local\Temp\scoped_dir9668_31484\internal" --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12606 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\OLIVIE~1.VER\AppData\Local\Temp\scoped_dir9668_609" data:,
[2.035][INFO]: RESPONSE InitSession unknown error: chrome failed to start
[2.035][DEBUG]: Log type 'driver' lost 0 entries on destruction
[2.035][DEBUG]: Log type 'browser' lost 0 entries on destruction

我已经查看了我能找到的几乎所有类似的问题,例如 this onethis one,但我遇到的所有解决方案都没有帮助,我得到的总是同样的错误.我尝试过十几种不同的设置时遇到了同样的错误。

几个月前,我记得我在同一台机器上成功地为另一个项目运行了 chromedriver。

我想我已经提供了所有必要的信息,但如果我忘记了什么,请随时在 cmets 中问我。

谢谢

【问题讨论】:

  • 硒版本是什么?
  • @DavidePatti 最新来自一个新鲜的pip install,所以那将是selenium 3.7.0。我承认我还没有考虑过尝试其他版本的 selenium。
  • 好吧,我试过 selenium 3.6.03.5.0 每次还是一样的错误。
  • 在错误中指出它正在启动 chrome.exe 而不是 chromedriver.exe... 这正常吗?我会期待chromedriver.exe。你确定你的exe路径是正确的吗?

标签: python selenium selenium-chromedriver


【解决方案1】:

错误说明了一切Cannot switch to US keyboard layout - some keys may be interpreted incorrectly。此错误引入了更多错误:

[2.035][INFO]: RESPONSE InitSession unknown error: chrome failed to start
[2.035][DEBUG]: Log type 'driver' lost 0 entries on destruction
[2.035][DEBUG]: Log type 'browser' lost 0 entries on destruction

所以基本上这个错误不是SeleniumChrome 本身。

这里有 3 个最好的solutionsto yourproblem


更新:

当您摆脱了错误Cannot switch to US keyboard layout - some keys may be interpreted incorrectly,但您仍然看到WebDriverException: Message: unknown error: chrome failed to start,请按照以下步骤操作:

  1. 卸载 ChromeRevo UninstallerModerate Memory Scan,以便清除不需要的注册表项。
  2. 在执行 Tests 之前和之后运行 CCleaner 工具以清除所有操作系统杂务。
  3. Reboot 你的系统。
  4. Execute 你的Test 为:

    driver=webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')
    

【讨论】:

  • 我已经尝试过了,现在我在输出日志中不再出现Cannot switch to US keyboard layout - some keys may be interpreted incorrectly 错误,但是除了这一行消失之外,日志完全一样,并且启动 chromedriver 时的错误仍然存​​在也一样。
  • 我也不确定键盘布局会如何阻止驱动程序像这样启动。
  • 好吧,在这样做之后,我什至无法再安装 Chrome。安装程序抛出一个错误,说我已经在这台机器上安装了 Chrome,我应该先卸载它,但我在我的机器上找不到它的丝毫痕迹......太好了
  • @Verv 太好了!!!所以现在我们找到了核心问题。让我们一劳永逸地解决这个问题。
  • @Verv 在重新启动之前,您是否接受了 Revo Uninstaller 和 CCleaner 的帮助?
【解决方案2】:

我最终经历了无数种不同的解决方案,但没有任何结果,但最终似乎真正解决了这个问题的是:

  • 卸载 Chrome
  • 检查 Windows 注册表并删除每个名为 {8A69D345-D564-463C-AFF1-A69D9E530F96} 的键
  • 重新安装 Chrome

在遵循DebanjanB's answer 的解决方案后,我最终得到了这个解决方案,并且无法再安装 Chrome。搜索这个新问题让我找到了this post

Remember to backup your registry before doing this.

完成此操作后,我能够重新安装 Chrome 并运行 chromedriver。

【讨论】:

    猜你喜欢
    • 2014-10-08
    • 2023-01-19
    • 2014-04-20
    • 1970-01-01
    • 2016-10-08
    • 2018-02-07
    • 2022-12-17
    • 1970-01-01
    • 2017-09-07
    相关资源
    最近更新 更多