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.)