If anybody has been struggling with Selenium driver initialisation on Streamlit cloud hosting, this post should help.
If you are experiencing the following two errors, then this post should definitely help you:
Error snippet from log:
WebDriverException: Message: Service
/home/appuser/.cache/selenium/chromedriver/linux64/136.0.7103.49/chromedriver
unexpectedly exited. Status code was: 127
Error snippet from app:
selenium.common.exceptions.WebDriverException: This app has encountered an error.....
...
raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
Solved thanks to this post below, from screenshot-app:
After some trial and error, the problem can be resolved by adding packages.txt file, that contains “chromium” into your project.
If you want to find more about packages.txt and dependencies, visit: App dependencies for your Community Cloud app - Streamlit Docs
My assumption on why it works now, is from this post: https://stackoverflow.com/questions/49323099/webdriverexception-message-service-chromedriver-unexpectedly-exited-status-co
, where thanks to packages.txt and chromium, the app installs some additional external libraries, that resolves problem with the Selenium webdriver.
PS: If anybody finds exactly which external libraries resolve the problem with the webdriver, comment below.