3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【備忘録】seleniumエラー対応(ChromeDriver is assuming that Chrome has crashed)

Last updated at Posted at 2022-09-19

エラー内容および対処法

実行環境:
Ubuntu 20.04 LTS
Python 3.8.9

エラー内容
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /snap/chromium/2082/usr/lib/chromium-browser/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

かなり苦戦しましたが、下記対処で解決できました。
 ・「--no-sandbox」オプションの追加
 ・chromeのパスを指定

サンプル
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options


options = Options();
options.add_argument('--no-sandbox')
options.add_argument('--headless')
options.binary_location = '/usr/bin/chromium-browser'
driver = webdriver.Chrome(options=options)
driver.get('https://◯◯◯◯◯◯◯◯')
time.sleep(5)
print(driver)
time.sleep(5)
driver.quit()

chromium-browserのインストールは下記にて。

sudo apt install -y chromium-browser

メモ

「google-chrome」のパスを指定するという記事もあったのですが、私の場合はそれでは解決しませんでした。

詳しくは不明、、、
また何か分かりましたら追記します。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?