WebDriverException: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist)

10,609

This is for java, but I think it should work for you to: https://github.com/SeleniumHQ/selenium/issues/4961#issuecomment-346821657
It says that is is a permission issue. Try running your program as root.

Share:
10,609

Related videos on Youtube

Ethan Hill
Author by

Ethan Hill

Updated on June 04, 2022

Comments

  • Ethan Hill
    Ethan Hill almost 2 years

    Python script using Selenium can't create an instance of Chrome, despite the versions being correct and a UI being installed.

    I've already taken a look at similar threads here, none of which appear to have solved the issue. The code works on Windows - it no longer works once I try to execute it on Linux. My intended goal is for it to open Chrome visually, and as such I am not looking for a solution that involves virtual displays.

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    options.add_argument('--disable-dev-shm-usage')
    options.add_argument('--no-sandbox')
    
    driver = webdriver.Chrome('/home/ethan/chromedriver', chrome_options=options)
    driver.set_window_size(1024, 600)
    driver.maximize_window()
    

    I have Google Chrome 75.0.3770.100 installed I also have ChromeDriver 75.0.3770.90

    Here is the full traceback from the code:

    File "cm_update_01.py", line 114, in <module>
        if __name__ == "__main__": main()
      File "cm_update_01.py", line 24, in main
        with open(fetch_file()) as f:
      File "cm_update_01.py", line 75, in fetch_file
        driver = webdriver.Chrome('/home/ethan/chromedriver', chrome_options=options)
      File "/home/ethan/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
        desired_capabilities=desired_capabilities)
      File "/home/ethan/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
        self.start_session(capabilities, browser_profile)
      File "/home/ethan/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
        response = self.execute(Command.NEW_SESSION, parameters)
      File "/home/ethan/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
        self.error_handler.check_response(response)
      File "/home/ethan/.local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
        raise exception_class(message, screen, stacktrace)
    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 /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
    
    • Michael Reinsch
      Michael Reinsch almost 5 years
      This is actually not a duplicate issue, but seems to be an issue with ChromeDriver 75.0.3770.90. After downgrading to ChromeDriver 74.0.3729.6 all works fine for me.
  • Ethan Hill
    Ethan Hill almost 5 years
    I ran the execution command as root, but the console returned the same error.
  • Foo bar
    Foo bar almost 5 years
    Try adding the --single-process flag
  • Foo bar
    Foo bar almost 5 years
    If you look here: stackoverflow.com/questions/50642308/…, you will find that ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session. The arg you are using to stop it only works on Linux, so add these flags too: --disable-extensions, --disable-gpu, disable-infobars, start-maximized.
  • Ethan Hill
    Ethan Hill almost 5 years
    I tested the process twice, once with only the secondly mentioned flags (disable-extensions, etc...) and once with the --single-process flag enabled. Both times, the flags did not appear to fix the issue, and the error came back the same as from the original post. I'm on Ubuntu 18.04.2.
  • Foo bar
    Foo bar almost 5 years
    What Version python are you using?
  • Foo bar
    Foo bar almost 5 years
    Also try the Firefox drivers. github.com/mozilla/geckodriver/releases
  • Ethan Hill
    Ethan Hill almost 5 years
    Python 3.6 is my current version