Forums

Without change in code I am getting a Chromium error

No changes at all to my code but I am getting this:

File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 76, in __init__
    RemoteWebDriver.__init__(
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.9/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/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
**NO MATCH**

Does anyone know if there was a change to Chromium or the system? Interestingly if I run a small test script with the ** exact same code ** everything seem to work.

Hello, we haven't changed anything that would cause this, however you seem to be on an older system image. Upgrading to the latest system image is likely to help with this kind of issue. We have a help page on how to upgrade here: https://help.pythonanywhere.com/pages/ChangingSystemImage/

I updated the system image but the error persists. Again, I didn't change any code at all ... here is the code that is generating the error all the sudden a few days ago.

def openWebDriver():

    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("--no-sandbox")
    chrome_options.add_argument("--disable-gpu")
    chrome_options.add_argument('--disable-dev-shm-usage')
    web_driver = webdriver.Chrome(options=chrome_options)

    return web_driver

How are you using web_driver in your code? How many isntances of it is it creating? Is it possible that you're starting multiple browsers without closing them?

No, every browser is closed just after the data is captured. Also, as I mentioned, this worked without fail for months until a few days ago.

How are you running the code on PythonAnywhere?

Mine stopped working too but on Colab. Issue may be not related but I found a fix here https://github.com/googlecolab/colabtools/issues/3347