Complementing @Michael Mintz 's approach,here's a possible fix I tried and worked: Automatically set the version_main from the Error log Using a regular Expression as shown in the snippet below:
import re
import undetected_chromedriver as uc
def initialize_session():
try:
sess = uc.Chrome()
except Exception as e:
main_version_string = re.search(r"Current browser version is (\d+\.\d+\.\d+)", str(e)).group(1)
main_version = int(main_version_string.split(".")[0])
sess = uc.Chrome(version_main=main_version)
return sess