Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

Before I begin: I know there are a billion posts about Selenium not working, and various solutions to try. 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. Afterwords, I started the chromedriver with ./chromedriver .

I've tried various options for Selenium, including manually adding the port that the chromedriver is running on

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.

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.

I would recommend using the headless option and in a project ive used the .implicitly_wait(10) function before calling any website. I would also choose chromium as driver. – Lukas Marschall Dec 23, 2021 at 18:54 Thanks for your reply! I gave up and tried Firefox instead, which I got working first try. This situation is still a mystery to me, and I appreciate anyone's opinions on what might be wrong in the above code. – generic Dec 23, 2021 at 19:33

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. 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 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?
  • Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •