'python heroku- Message: unknown error: Chrome failed to start: crashed. (chrome not reachable)

I'm trying to host a flask website on heroku. This website uses python and selenium (chrome). Whenever I try to run my code, I get the error:

Message: unknown error: Chrome failed to start: crashed. (chrome not reachable) (The process started from chrome location /app/.apt/opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Stacktrace: #0 0x5560e4c72533 #1 0x5560e49d11e8 #2 0x5560e49f454a #3 0x5560e49efc4a #4 0x5560e4a2ad0a #5 0x5560e4a24e33 #6 0x5560e49fa71a #7 0x5560e49fb875 #8 0x5560e4cb6e1d #9 0x5560e4cba751 #10 0x5560e4ca107e #11 0x5560e4cbb388 #12 0x5560e4c95fe0 #13 0x5560e4cd7748 #14 0x5560e4cd78c8 #15 0x5560e4cf170d #16 0x7f7ba500a609

I've looked at resources and other stack overflow questions that suggest:

Create Aptfile in the root folder with libxshmfence-dev inside.

However this does nothing.

Driver:

chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
chrome_options.headless = True
chrome_options.add_argument("log-level=3")
chrome_options.add_experimental_option(
    "excludeSwitches", ["enable-logging"])
chrome_options.add_argument("--remote-debugging-port=9222")
driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"), chrome_options=chrome_options)

Heroku buildpacks: Buildpacks

I'd appreciate any help. Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source