[Python] Problems in running Selenium in EC2

Discussão em 'Python' iniciado por Stack, Agosto 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm having problems in running my python program on Amazon EC2. Everytime I try it gives me the following error:

    Traceback (most recent call last):
    File "/home/ubuntu/precobtc.py", line 22, in <module>
    driver = webdriver.Firefox(service = service, options =options)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/ubuntu/meu_bot_venv/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 72, in __init__
    super().__init__(command_executor=executor, options=options)
    File "/home/ubuntu/meu_bot_venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 263, in __init__
    self.start_session(capabilities)
    File "/home/ubuntu/meu_bot_venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 366, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/ubuntu/meu_bot_venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 458, in execute
    self.error_handler.check_response(response)
    File "/home/ubuntu/meu_bot_venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#sessionnotcreatedexception

    (meu_bot_venv) ubuntu@ip-172-31-34-5:~$ client_loop: send disconnect: Broken pipe


    my version of firefox is 142.0 and geckodriver is 0.36.0. Selenium is 4.35.0.

    here is the code on how I'm trying to initialize it:

    import pandas as pd # Importe pandas para lidar com séries temporais
    from selenium.webdriver.firefox.service import Service
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.common.by import By
    import requests
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC

    service = Service(executable_path="/usr/local/bin/geckodriver")
    options = Options()
    options.add_argument("--no-sandbox")
    options.add_argument("--headless")
    driver = webdriver.Firefox(service = service, options =options)

    Continue reading...

Compartilhe esta Página