尝试启动 Firefox 时出现 Python Selenium 错误

2024-01-15

我在 ipython 笔记本中尝试使用 Selenium 打开 Firefox 时遇到错误。我环顾四周,发现了类似的错误,但没有任何错误与我收到的错误完全匹配。有人知道问题可能是什么以及我如何解决它吗?我使用的是 Firefox 22。

我输入的代码如下:

from selenium import webdriver
driver = webdriver.Firefox()

代码返回的错误如下:

    WindowsError                              Traceback (most recent call last)
<ipython-input-7-fd567e24185f> in <module>()
----> 1 driver = webdriver.Firefox()

C:\Anaconda\lib\site-packages\selenium\webdriver\firefox\webdriver.pyc in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy)
     56         RemoteWebDriver.__init__(self,
     57             command_executor=ExtensionConnection("127.0.0.1", self.profile,
---> 58             self.binary, timeout),
     59             desired_capabilities=capabilities)
     60         self._is_remote = False

C:\Anaconda\lib\site-packages\selenium\webdriver\firefox\extension_connection.pyc in __init__(self, host, firefox_profile, firefox_binary, timeout)
     45         self.profile.add_extension()
     46 
---> 47         self.binary.launch_browser(self.profile)
     48         _URL = "http://%s:%d/hub" % (HOST, PORT)
     49         RemoteConnection.__init__(

C:\Anaconda\lib\site-packages\selenium\webdriver\firefox\firefox_binary.pyc in launch_browser(self, profile)
     45         self.profile = profile
     46 
---> 47         self._start_from_profile_path(self.profile.path)
     48         self._wait_until_connectable()
     49 

C:\Anaconda\lib\site-packages\selenium\webdriver\firefox\firefox_binary.pyc in _start_from_profile_path(self, path)
     71 
     72         Popen(command, stdout=PIPE, stderr=STDOUT,
---> 73               env=self._firefox_env).communicate()
     74         command[1] = '-foreground'
     75         self.process = Popen(

C:\Anaconda\lib\subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
    677                             p2cread, p2cwrite,
    678                             c2pread, c2pwrite,
--> 679                             errread, errwrite)
    680 
    681         if mswindows:

C:\Anaconda\lib\subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
    894                                          env,
    895                                          cwd,
--> 896                                          startupinfo)
    897             except pywintypes.error, e:
    898                 # Translate pywintypes.error to WindowsError, which is

WindowsError: [Error 2] The system cannot find the file specified

尝试在初始化时指定您的 Firefox 二进制文件Firefox()

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('path/to/binary')
driver = webdriver.Firefox(firefox_binary=binary)

FirefoxDriver 寻找的默认路径位于%PROGRAMFILES%\Mozilla Firefox\firefox.exe. See Firefox驱动程序 https://github.com/SeleniumHQ/selenium/wiki/FirefoxDriver

或者将 Firefox 二进制文件的路径添加到 Windows'PATH http://www.computerhope.com/issues/ch000549.htm#0.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

尝试启动 Firefox 时出现 Python Selenium 错误 的相关文章

随机推荐

  • Camera.PictureCallback 拍照后停止预览

    使用具有 Android API 16 的设备拍照后 预览停止工作 但当我使用具有 Android API 22 的设备时 应用程序工作正常 我有这个拍照代码 private Camera PictureCallback mPicture
  • 连接sqlite中未知数量的值

    我正在使用 sqlite 3 15 1 我有一张桌子master包含大学的主时间表 看起来像 day sem sec hour sub id MON 5 B 4 10IS51 MON 5 B 4 10IS53 MON 5 B 5 10CS5
  • 更改 Three.js 对象的几何形状

    我正在尝试更改 Three js 场景中某些对象的几何形状 我有一段几乎可以工作的代码 其中鼠标单击触发了更改 但遇到了以下问题 渲染的 形状仅在第一次鼠标单击时更改 即使几何图形也发生了变化通过以下每次点击都成功修改 使用 Three j
  • 如何让 nasm 在 MacOS 终端中作为命令工作?

    我一直在尝试让 nasm 作为终端中的命令工作 但似乎没有任何效果 我只是不断收到错误 nasm error unable to find utility nasm not a developer tool or in PATH 因此 首先
  • 在javaScript中刷新页面后如何更新数据库?

    我想给用户机会更改产品的评分值 但刷新页面后不起作用 例如 当他访问一个他没有评分的新产品时 他可以在刷新页面之前一次又一次地更改评分值 但刷新页面后 他可以更改同一产品的评级值 但 ratingValue2 的警报不起作用 数据库也没有更
  • 两个 pdf 水印 - 第一个的每一页和第二个的每一页

    我有两个长度相同的 pdf 文件 比如说 pdf1 pdf 和 pdf2 pdf 我正在尝试使用 pdf2 pdf 为 pdf1 pdf 的每一页添加水印 即 pdf1 pdf 第 1 页与 pdf2 pdf 第 1 页 pdf1 pdf
  • 如何从 imblearn 中的 RandomUnderSampler 获取样本索引

    有谁知道使用 imblearn 的 RandomUnderSampler 进行欠采样后是否 如何获得所选样本的索引 曾经有一个参数 return indices True 现在在新版本中被删除 并且可能被属性 sample indices
  • 如何在未安装 Git 的情况下应用“git diff”补丁?

    我的客户如何应用由git diff没有安装git 我尝试过使用patch命令 但它总是询问要修补的文件名 git diff gt patchfile and patch p1 lt patchfile 工作 但正如许多人在评论和其他答案中注
  • 检测移动 Web 应用程序是否位于本机 Facebook 应用程序中

    有没有办法检测我们的移动 Web 应用程序是否显示在本机 Facebook iOS 应用程序的 WebView 内 或者是否独立运行 据我们了解 我们不允许从他们的框架内获取 Facebook 积分 但我们are允许从我们自己的独立 Web
  • VBA宏使用单元格路径保存Excel文件

    我正在尝试使用硬线和单元格值的组合来保存文件以确定文件路径 In cell A29 我有一个输出这个的公式 2014 1月 高额现金 1 7 14 我得到一个预期 声明结束 error 代码是 ActiveWorkbook SaveAs F
  • 正则表达式替换%variables%

    我已经用了 30 分钟的时间来拔一撮头发了 我有一本字典 像这样 search replace foo bar 还有一个像这样的字符串 Foo bar foo search 我想用字典中的等效文本替换每个变量 Foo bar bar rep
  • Gradle:如何在控制台上打印依赖项工件 URL

    我们从maven转移到gradle 在maven中 使用build命令 我们可以清楚地看到从中获取依赖项的nexus URL 使用 gradle 我如何在项目构建时查看依赖项 URL 是否有任何命令行选项可以在 gradle 中执行此操作
  • 如何在 Laravel 队列中使用模型

    我正在尝试将邮件列表从 CSV 导入到我的数据库中 我的 Laravel 中有两个模型负责执行此操作 Target and Mailing one Target有很多Mailings 我正在使用带有 Beanstalkd 的队列系统 我在用
  • Redmine 3.3.0 (ruby on Rails 4.2.6) 样式表未生成/包含在 application.css 中

    我已经安装了 redmine 并设法启动它 但 UI 似乎缺少它的 css 样式 如果我点击 application SomeId css 的链接 它会显示一个包含以下消息的空 css This is a manifest file tha
  • UIGestureRecognizer 接收触摸但也将其转发给 UIControl

    你会如何允许UIGestureRecognizer of a UIView接收触摸事件 但也确保另一个 底层 上层UIView也收到同样的触摸事件 Lets say I have got the following view hierach
  • 三角形带上的纹理坐标

    我创建了一个带有 14 个顶点的几何着色器的立方体 感谢三角形条 现在的问题是如何放置我的纹理坐标 我有一个包含 3 个纹理的图像文件 立方体的顶面 底面 左 右 前 后面 我找不到为每个顶点提供纹理坐标的方法 14 我总是得到奇怪的纹理显
  • Python 3.5.1:QVariant 表示映射类型,无法实例化

    我正在使用 Python 3 5 1 我正在尝试运行此代码 但 QVariant 有问题 from PyQt4 QtCore import from PyQt4 QtGui import import sys class Model QAb
  • Python 多处理:比请求的进程更多

    为什么我看到这么多 python 进程在运行 在htop on RHEL 6 当我只使用 1 个核心时 对于相同的脚本 对于每个任务 我都会初始化一个管理处理的工作类 它会初始化其他类 但不会初始化任何子进程 tasks multiproc
  • Android SDK 的快速位图模糊

    目前 在我正在开发的 Android 应用程序中 我正在循环遍历图像的像素以使其模糊 对于 640x480 图像 这大约需要 30 秒 在浏览 Android Market 中的应用程序时 我遇到了一个包含模糊功能的应用程序 并且它们的模糊
  • 尝试启动 Firefox 时出现 Python Selenium 错误

    我在 ipython 笔记本中尝试使用 Selenium 打开 Firefox 时遇到错误 我环顾四周 发现了类似的错误 但没有任何错误与我收到的错误完全匹配 有人知道问题可能是什么以及我如何解决它吗 我使用的是 Firefox 22 我输