You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Selenium启动Firefox报错:Process unexpectedly closed with status 11

问题:Nobara(基于Fedora 36)运行Selenium Python脚本触发WebDriverException(状态码11)

环境与代码

Python脚本

"First selenium script"
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager


driver = webdriver.Firefox(
    service=FirefoxService(executable_path=GeckoDriverManager().install()))

.driver.get("https://www.google.com")

控制台错误输出

alex@nobara ~/selenium$ python main.py
Traceback (most recent call last):
  File "/home/alex/selenium/main.py", line 7, in <module>
    driver = webdriver.Firefox(
  File "/home/alex/.local/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 177, in __init__
    super().__init__(
  File "/home/alex/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 272, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/alex/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 364, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/alex/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
  File "/home/alex/.local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 11

Geckodriver日志

1666974769008   geckodriver INFO    Listening on 127.0.0.1:58881
1666974769634   mozrunner::runner   INFO    Running command: "/usr/bin/firefox" "--marionette" "--remote-debugging-port" "56809" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "/tmp/rust_mozprofile6UjIeC"
ExceptionHandler::GenerateDump cloned child 6111
ExceptionHandler::WaitForContinueSignal waiting for continue signal...
ExceptionHandler::SendContinueSignalToChild sent continue signal to child

已尝试但无效的操作

  • 将/usr/local/bin中的GeckoDriver移至脚本所在的~/selenium目录并设置路径参数
  • 执行sudo chmod -R 777 ~/selenium/修改权限
  • 通过about:support重置Firefox并禁用所有扩展

解决方案

1. 修复脚本语法错误

脚本中.driver.get("https://www.google.com")多了一个前置句点,正确写法应为driver.get("https://www.google.com"),这个语法错误可能直接导致进程异常终止。

2. 严格匹配Geckodriver与Firefox版本

状态码11多数由二进制文件版本不兼容引发崩溃,需确保两者版本严格对应:

  • 查看本地Firefox版本:执行firefox --version
  • 下载对应版本的Geckodriver,替换现有文件后赋予执行权限:chmod +x geckodriver

3. 临时禁用Firefox Sandbox测试

Nobara基于Fedora,可能存在Sandbox权限冲突,可添加启动参数绕过:
修改脚本添加FirefoxOptions配置:

from selenium.webdriver.firefox.options import Options

options = Options()
options.add_argument("--no-sandbox")

driver = webdriver.Firefox(
    service=FirefoxService(executable_path=GeckoDriverManager().install()),
    options=options)
driver.get("https://www.google.com")

注意:禁用Sandbox会降低安全性,仅用于排查问题,生产环境不建议使用。

4. 安装缺失的系统依赖

Fedora系统可能缺少Firefox运行所需的依赖包,执行以下命令补全:

sudo dnf install -y firefox-libs alsa-lib dbus-glib gtk3 libX11 libXcomposite libXdamage libXext libXfixes libXrender libXtst nspr nss

5. 使用系统包管理安装Geckodriver

避免webdriver-manager自动安装的版本不兼容,直接通过dnf安装适配系统的版本:

sudo dnf install -y geckodriver

修改脚本直接调用系统路径的Geckodriver:

driver = webdriver.Firefox(service=FirefoxService(executable_path="/usr/bin/geckodriver"))

内容的提问来源于stack exchange,提问作者Alessio Di Stasi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 20:15:42