selenium: [🐛 Bug]: webdriver - Process unexpectedly closed with status 127 (Geckodriver)

What happened?

Hi!

Just trying to start working with Geckodriver get the following exception: “selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127”.

Using Chrome driver the code below works fine.

webdriver-manager==3.8.5 selenium==4.7.2

Thanks in advance

How can we reproduce the issue?

# Try to start this script

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager

opts = Options()
opts.log.level = "trace"
opts.add_argument('--headless')

# ------ Process unexpectedly closed with status 127
driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))

# ------ Process unexpectedly closed with status 127
#driver = webdriver.Firefox(options=opts, executable_path=GeckoDriverManager().install())
#driver = webdriver.Firefox(executable_path="/media/dmz/HDD/geckodriver/geckodriver")

# ------ Process unexpectedly closed with status 127
#service = FirefoxService(executable_path="/media/dmz/HDD/geckodriver/geckodriver")
#driver = webdriver.Firefox(options=opts, service=service)

driver.get('https://google.com')

print(driver.title)

Relevant log output

[WDM] - Downloading: 19.0kB [00:00, 6.53MB/s]                   
Traceback (most recent call last):
  File "/media/dmz/HDD/RPT/Python/techPanda/debug.py", line 11, in <module>
    driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
  File "/media/dmz/HDD/RPT/Python/techPanda/venv/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 197, in __init__
    super().__init__(command_executor=executor, options=options, keep_alive=True)
  File "/media/dmz/HDD/RPT/Python/techPanda/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 288, in __init__
    self.start_session(capabilities, browser_profile)
  File "/media/dmz/HDD/RPT/Python/techPanda/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 381, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/media/dmz/HDD/RPT/Python/techPanda/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 444, in execute
    self.error_handler.check_response(response)
  File "/media/dmz/HDD/RPT/Python/techPanda/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 249, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127

Operating System

Linux Mint 20.3 x86_64; 5.4.0-135-generic

Selenium version

selenium==4.7.2

What are the browser(s) and version(s) where you see this issue?

Browser doesn’t start, Firefox version = 107.0.1 (64)

What are the browser driver(s) and version(s) where you see this issue?

geckodriver-v0.32.0-linux64

Are you using Selenium Grid?

NO

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Following @titusfortner 's advice and this, the following works for me, within PyCharm and not needing to do anything special regarding Firefox profile locations:

    install_dir = "/snap/firefox/current/usr/lib/firefox"
    driver_loc = os.path.join(install_dir, "geckodriver")
    binary_loc = os.path.join(install_dir, "firefox")

    service = FirefoxService(driver_loc)
    opts = webdriver.FirefoxOptions()
    opts.binary_location = binary_loc
    driver = webdriver.Firefox(service=service, options=opts)

Note that the opts.binary_location is required, not just the driver location.

/snap/firefox/current is a symlink to the current version directory within /snap/firefox, so I’m hoping that is a better way to dynamically keep pointed at the right binary + driver, without the subprocess("find ...") hack in the SO answer

Snap is a pain for selenium. It has its own driver and none of the driver managers support it. You need to explicitly pass on the location to the driver in the service constructor.

@self-dmz are you also using snap?

@AntiPetrun Hi! Check your imports, because in issue description more common Service was imported as FirefoxService (with other module name)

from selenium.webdriver.firefox.service import Service as FirefoxService

Hi, guys! I have such problem: NameError: name ‘FirefoxService’ is not defined