I'm trying to setup a python application that uses Selenium and Chrome on PythonAnywhere. Everything is working in a development environment but I am running into issues when trying to deploy to PythonAnywhere. I'm getting the following traceback when attempting to run the code:
Traceback (most recent call last):
File "/home/mattk/Door_Price/main.py", line 51, in <module>
main()
File "/home/mattk/Door_Price/main.py", line 13, in main
catalog = Catalog(silent=True)
File "./driver.py", line 29, in __init__
self.driver = self._create_engine(path or config.PATH, silent)
File "./driver.py", line 60, in _create_engine
driver = Chrome(
File "/usr/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 65, in __init__
RemoteWebDriver.__init__(
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, 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-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}),platform=Linux 5.4.0-1020-aws x86_64)
Not sure if PythonAnywhere needs some special configurations? Any help on this issue would be greatly appreciated.
Code causing error: @staticmethod def _create_engine(path, silent): """Generate Selenium Engine"""
# TODO check if driver is present
if silent:
options = ChromeOptions()
options.add_argument('--headless')
driver = Chrome(
executable_path=path,
options=options
)
else:
driver = Chrome(
executable_path=path
)
return driver
File "/home/mattk/Door_Price/main.py", line 13, in main catalog = Catalog(silent=True)can you add this part of the code.