gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 11:48:50 24 4
gpt4 key购买 nike

最近我换了电脑,从那以后我就不能用 Selenium 启动 chrome 了。我也尝试过 Firefox,但浏览器实例无法启动。

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)

最佳答案

尝试在此处下载并使用最新的 chrome 驱动程序版本:

试试这个:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

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/<user>/chromedriver',chrome_options=chrome_options)
d.get('https://www.google.nl/')

关于python - Selenium:WebDriverException:Chrome 无法启动:由于 google-chrome 不再运行而崩溃,因此 ChromeDriver 假设 Chrome 已崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56751032/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com