Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed
Try to download HERE and use this latest chrome driver version:
- https://sites.google.com/chromium.org/driver/
Try this:
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/')
chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed error using Selenium through Python
You need to take care of a couple of things as follows:
options.binary_location
: Refers to the google-chrome binary location and is used if Google Chrome isn't installed at the default location. See: WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome--remote-debugging-port
: If you aren't remote debugging, you can drop this argument safely.chrome_driver_binary
: Referes to the absolute location of the ChromeDriver within your system.webdriver.Chrome(chrome_driver_binary, options = options)
: Additionally you may like to add the key executable_path as as follows: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.
The minimum code block to initiate a Selenium driven ChromeDriver initiated google-chrome Browsing Context can be:
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. 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. You need to configure your environment to run Chrome as a regular user instead.
References
You can find a couple of relevant detailed discussions in:
- How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium?
Selenium: Chrome failed to start: exited abnormally
From https://stackoverflow.com/a/70265091/13508045
Add :/usr/bin:/bin
to your PATH as shown below:
Environment="PATH=/home/admini/websites/myapp/venv/bin:/usr/bin:/bin"
Complete file looks like this:
[Unit]
Description=uWSGI instance to serve myapp
After=network.target
[Service]
User=admini
Group=www-data
WorkingDirectory=/home/admini/websites/myapp
Environment="PATH=/home/admini/websites/myapp/venv/bin:/usr/bin:/bin"
ExecStart=/home/admini/websites/myapp/venv/bin/uwsgi --ini myapp.ini
[Install]
WantedBy=multi-user.target
Related Topics
Putting French (Accented) Characters in Ruby File
Rufus Scheduler Not Running in Production
Libmysqlclient.So.15: Cannot Open Shared Object File: No Such File or Directory
How to Update Ruby on Linux (Ubuntu)
Rescue in Rbuf_Fill': Timeout::Error (Timeout::Error)
Rails Dot Instead of Slash in Url
Calculating the Number of Weeks in a Year with Ruby
Database.Yml &References Not Working
The <<- Operator on Ruby, Where Is It Documented
Character Encoding Issue in Rails V3/Ruby 1.9.2
Rails Catch-All/Globbing Routes
Error: Error Installing Ffi: Error: Failed to Build Gem Native Extension
Is the &Method(:Method_Name) Idiom Bad for Performance in Ruby
Ruby on Rails: Advanced Search