Python WebDriverException:消息:“geckodriver”可执行文件需要在 PATH 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40188699/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 23:15:07  来源:igfitidea点击:

WebDriverException: Message: 'geckodriver' executable needs to be in PATH

pythonselenium

提问by pratap

os:windows 7 selenium version 3.0.1 mozilla firefox:48.0.2

操作系统:windows 7 selenium 版本 3.0.1 mozilla firefox:48.0.2

Traceback (most recent call last):
  File "C:\Users\LENOVO\Desktop\kk2.py", line 4, in <module>
  driver = webdriver.Firefox()
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__
  self.service.start()
  File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
  os.path.basename(self.path), self.start_error_message)
  WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

please give information step by step thoroughly please actually i am learner

请逐步详细地提供信息,实际上我是学习者

回答by ahereza

For Linux based system, download geckodriver. Extract it and copy the driver to /usr/local/bin and finally make it executable (chmod +x geckodriver).

对于基于 Linux 的系统,下载geckodriver。提取它并将驱动程序复制到 /usr/local/bin 并最终使其可执行(chmod +x geckodriver)。

回答by Naveen Kumar R B

please check the answer:

请检查答案:

https://stackoverflow.com/a/37765661

https://stackoverflow.com/a/37765661

https://stackoverflow.com/a/40208762

https://stackoverflow.com/a/40208762

Shortly,

不久,

From selenium 3.0, you have to explicitly download Marionette geckodriverfor Firefox (which is similar to ChromeDriver for Chrome) and keep it in a place where the system can identify it. (like System PATH - environmental variables in Windows) or specify using language options.

从 selenium 3.0 开始,您必须明确下载Marionette geckodriverFirefox(类似于 ChromeDriver for Chrome)并将其保存在系统可以识别的地方。(如系统路径 - Windows 中的环境变量)或指定使用语言选项。

References:

参考:

  1. Download Marionette GeckoDriver
  2. https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
  3. https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette
  1. 下载 Marionette GeckoDriver
  2. https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
  3. https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette

回答by elad silver

For mac users use:

mac 用户使用:

brew install geckodriver

回答by Emily Chen

I just download Gecko file and paste in where your python file is. It solves the problem!

我只是下载 Gecko 文件并粘贴到您的 python 文件所在的位置。它解决了问题!

回答by Tushar Goyal

Linux(Ubuntu) Users should download the geckodriver and extract it in your project folder and while running your python script give the argument as

Linux(Ubuntu) 用户应该下载 geckodriver 并将其解压缩到您的项目文件夹中,并在运行您的 python 脚本时将参数作为

executable_path="./geckodriver"

Example:

例子:

from selenium import webdriver

class RunFFTests():

    def testMethod(self):
        # Initiate the driver instance
        driver = webdriver.Firefox(
            executable_path="./geckodriver")

        driver.get("http://www.letskodeit.com")

ff = RunFFTests()
ff.testMethod()