[Python] Selenium chrome session not created and not accessible

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have several automation scripts that I need to access my chrome profile for it to work, but when I went to run today, all my scripts that I need chrome automated with my profile logged in this error is given:

    Traceback (most recent call last):
    File "c:\Users\Usuario\Documents\python\CatalogoMercadoLivre\teste.py", line 23, in <module>
    driver = setup_selenium()
    ^^^^^^^^^^^^^^^^
    File "c:\Users\Usuario\Documents\python\CatalogoMercadoLivre\teste.py", line 20, in setup_selenium
    driver = webdriver.Chrome(service=service, options=options)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Usuario\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__
    super().__init__(
    File "C:\Users\Usuario\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\selenium\webdriver\chromium\webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
    File "C:\Users\Usuario\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\selenium\webdriver\remote\webdriver.py", line 250, in __init__
    self.start_session(capabilities)
    File "C:\Users\Usuario\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\selenium\webdriver\remote\webdriver.py", line 342, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Usuario\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\selenium\webdriver\remote\webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
    File "C:\Users\Usuario\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\selenium\webdriver\remote\errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.SessionNotCreatedException: Message: session not created
    from chrome not reachable
    Stacktrace:GetHandleVerifier [0x00F6FBD3+61635]
    GetHandleVerifier [0x00F6FC14+61700]
    (No symbol) [0x00D9044E]
    (No symbol) [0x00D841DA]
    (No symbol) [0x00DC8F16]
    (No symbol) [0x00DC4017]
    (No symbol) [0x00DBF6C9]
    (No symbol) [0x00E08DF3]
    (No symbol) [0x00E0880A]
    (No symbol) [0x00DFD096]
    (No symbol) [0x00DCC840]
    (No symbol) [0x00DCD6A4]
    GetHandleVerifier [0x011B7043+2450739]
    GetHandleVerifier [0x011B27C6+2432182]
    GetHandleVerifier [0x011CD50E+2542078]
    GetHandleVerifier [0x00F86895+155013]
    GetHandleVerifier [0x00F8CF7D+181357]
    GetHandleVerifier [0x00F77428+92440]
    GetHandleVerifier [0x00F775D0+92864]
    GetHandleVerifier [0x00F61FC0+5296]
    BaseThreadInitThunk [0x76C05D49+25]
    RtlInitializeExceptionChain [0x777ECF0B+107]
    RtlGetAppContainerNamedObjectPath [0x777ECE91+561]


    The browser opens and is logged in, but nothing happens and the error is given my script is terminated.

    Chrome browser has been updated to the latest version: Google Chrome 136.0.7103.49 (Official version) 64-bit (cohort: Stable Installs & Version Pins)

    Version Chrome Driver: 136.0.7103.49


    • ChromeDriver I tried by absolute path, and by Webdriver_manager both only work without the google profile.


    • I've tried changing profiles, I have 3 chrome profiles, all 3 have the same thing happen, google opens with the corresponding profile and then returns the same error message.


    • I've also tried uninstalling and reinstalling webdriver from the terminal.

    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    from selenium.webdriver.chrome.options import Options
    from webdriver_manager.chrome import ChromeDriverManager
    def setup_selenium():
    #chrome_driver_path = "C:/Users/Usuario/Documents/python/CatalogoMercadoLivre/chromedriver.exe"
    #service = Service(chrome_driver_path)
    options = Options()
    options.add_argument("--disable-gpu")
    options.add_argument("--no-sandbox")
    options.add_argument("--disable-dev-shm-usage")
    options.add_argument("--disable-blink-features=AutomationControlled")
    options.add_argument("--remote-debugging-port=9222")
    options.add_argument("--start-maximized")

    options.add_argument(r"--user-data-dir=C:\Users\Usuario\AppData\Local\Google\Chrome\User Data")
    options.add_argument("--profile-directory=Profile 21")

    service = Service(ChromeDriverManager().install())
    driver = webdriver.Chrome(service=service, options=options)
    return driver

    driver = setup_selenium()
    driver.get("https://www.youtube.com")

    Continue reading...

Compartilhe esta Página