pythonselenium-webdriverselenium-chromedriverpythonanywhere

Selenium-based Flask application deployment on Pythonanywhere


I want to run Selenium via a POST request on Flask app, and want it to automate stuff. It is running perfectly locally, but when I try to deploy it on Pythonanywhere, I am getting errors like:

Error running WSGI application
Selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 90 Current browser version is 115.0.5790.170 with binary path /home/usmmsmsm/.cache/selenium/chrome/linux64/115.0.5790.170/chrome

I tried to update the browser via webdriver-manager, using the following code:

from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
# Initialize the WebDriver
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))

But then, I get the following error in error logs:

Error running WSGI application
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 90.0.4430.212 with binary path /usr/bin/chromium

This has really troubled me. Also, requesting Selenium via POST request in Flask app, and deployed on web, is it really possible as well? I will be grateful for an answer.


Solution

  • Don't use chromedriver manager on PythonAnywhere. Just use the default chromedriver and chrome that are already installed.