简体   繁体   English

chromedriver 不再运行,因此 ChromeDriver 假设 Chrome 使用 Selenium 到 Python 发生崩溃错误

[英]chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed error using Selenium through Python

Before I begin: I know there are a billion posts about Selenium not working, and various solutions to try.在我开始之前:我知道有十亿个关于 Selenium 不起作用的帖子,以及各种尝试的解决方案。 I believe I've tried everything, but forgive me if I am missing something.我相信我已经尝试了一切,但如果我遗漏了什么,请原谅我。 I'm hitting my head against a wall and would appreciate help.我的头撞在墙上,希望得到帮助。

Here are some steps I have taken:以下是我采取的一些步骤:

I downloaded the chromedriver for selenium (Ubuntu, Python) and used chmod 755 and also chmod 777 to make the driver executable.我下载了 selenium(Ubuntu,Python)的 chromedriver,并使用chmod 755chmod 777使驱动程序可执行。 Afterwords, I started the chromedriver with ./chromedriver .之后,我用 ./chromedriver 启动了./chromedriver

I've tried various options for Selenium, including manually adding the port that the chromedriver is running on我尝试了 Selenium 的各种选项,包括手动添加运行 chromedriver 的端口

from selenium import webdriver

options = webdriver.ChromeOptions()
options.binary_location = "/home/myname/projects/myproject/chromedriver"
options.add_argument("--remote-debugging-port=9515")
chrome_driver_binary = '/home/myname/projects/myproject/chromedriver'
driver = webdriver.Chrome(chrome_driver_binary, options = options)
driver.get('http://www.ubuntu.com/')

I've tried options suggested in other posts, like these:我已经尝试过其他帖子中建议的选项,例如:

options.add_argument('--no-sandbox')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("--disable-setuid-sandbox")

I've made sure that I am using a chromedriver that is compatable with my version of Chrome.我确保我使用的是与我的 Chrome 版本兼容的 chromedriver。

Nothing has seemed to work.似乎没有任何效果。 I keep getting this error:我不断收到此错误:

WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (chrome not reachable)
  (The process started from chrome location /home/myname/projects/myproject/chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

I'd sincerely appreciate someone else's interpretation of this problem.我真诚地感谢别人对这个问题的解释。

You need to take care of a couple of things as follows:您需要注意以下几点:

  • options.binary_location : Refers to the binary location and is used if Google Chrome isn't installed at the default location. options.binary_location :指的是二进制位置,如果Google Chrome未安装在默认位置,则使用该位置。 See: WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome请参阅: WebDriverException:未知错误:对于旧版本的 Google Chrome,在 Python 中找不到带有 Selenium 的 Chrome 二进制错误

  • --remote-debugging-port : If you aren't remote debugging, you can drop this argument safely. --remote-debugging-port :如果您不是远程调试,则可以安全地删除此参数。

  • chrome_driver_binary : Referes to the absolute location of the ChromeDriver within your system. chrome_driver_binary :指ChromeDriver在系统中的绝对位置。

  • webdriver.Chrome(chrome_driver_binary, options = options) : Additionally you may like to add the key executable_path as as follows: webdriver.Chrome(chrome_driver_binary, options = options) :此外,您可能希望添加key executable_path ,如下所示:

     chrome_driver_binary = '/home/myname/projects/myproject/chromedriver' driver = webdriver.Chrome(executable_path=chrome_driver_binary, options = options) driver.get('http://www.ubuntu.com/')
  • --no-sandbox , --headless , --disable-dev-shm-usage , --disable-setuid-sandbox , etc are optional settings which you may not require to start off. --no-sandbox--headless--disable-dev-shm-usage--disable-setuid-sandbox等是您可能不需要启动的可选设置。

The minimum code block to initiate a Selenium driven ChromeDriver initiated Browsing Context can be:启动Selenium驱动的ChromeDriver启动浏览上下文的最小代码块可以是:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
driver = webdriver.Chrome(executable_path='/home/myname/projects/myproject/chromedriver', options=options)
driver.get("http://www.ubuntu.com/")

A common cause for Chrome to crash during startup is running Chrome as root user ( administrator ) on Linux. Chrome 在启动期间崩溃的一个常见原因是在 Linux 上以root用户( administrator )身份运行 Chrome。 While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged.虽然可以通过在创建 WebDriver session 时传递--no-sandbox标志来解决此问题,但不支持并且强烈建议不要使用此类配置。 You need to configure your environment to run Chrome as a regular user instead.您需要将环境配置为以普通用户身份运行 Chrome。


References参考

You can find a couple of relevant detailed discussions in:您可以在以下位置找到一些相关的详细讨论:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium:WebDriverException:Chrome 无法启动:由于 google-chrome 不再运行而崩溃,因此 ChromeDriver 假设 Chrome 已崩溃 - Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed 从 chrome 位置 C:\\..\\Chrome\\Application\\chrome.exe 开始的进程不再运行,因此 ChromeDriver 假设 Chrome 已崩溃 - The process started from chrome location C:\..\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed WebDriverException:消息:未知错误:Chrome 无法启动:在 Amazon Linux 上通过 Selenium Python 使用 ChromeDriver Chrome 出现崩溃错误 - WebDriverException: Message: unknown error: Chrome failed to start: crashed error using ChromeDriver Chrome through Selenium Python on Amazon Linux 使用Selenium ChromeDriver中的ChromeOptions和通过Python的Chrome,“选项”对象没有属性“ set_preference”错误 - 'Options' object has no attribute 'set_preference' error using ChromeOptions in Selenium ChromeDriver and Chrome through Python AttributeError: 模块“selenium.webdriver”没有属性“Chrome”错误,使用 ChromeDriver 和 Chrome 通过 Selenium - AttributeError: module 'selenium.webdriver' has no attribute 'Chrome' error using ChromeDriver and Chrome through Selenium SessionNotCreatedException:此版本的 ChromeDriver 仅支持 Chrome 版本 84 使用 ChromeDriver 和 Chrome 通过 Selenium 和 Python - SessionNotCreatedException: This version of ChromeDriver only supports Chrome version 84 using ChromeDriver and Chrome through Selenium and Python ImportError: cannot import name 'Chromedriver' from 'selenium' error using ChromeDriver and Chrome through Selenium - ImportError: cannot import name 'Chromedriver' from 'selenium' error using ChromeDriver and Chrome through Selenium selenium.common.exceptions.WebDriverException: 消息:无法通过 Selenium Python 使用 ChromeDriver Chrome 连接到服务错误 - selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service error using ChromeDriver Chrome through Selenium Python 无法通过 Selenium 和 Python 使用 ChromeDriver 和 Chrome 登录 ebay 帐户 - Unable to signin into ebay account using ChromeDriver and Chrome through Selenium and Python selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:在 Python 中使用 ChromeDriver 和 Selenium 崩溃 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed with ChromeDriver and Selenium in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM