Python 3.5-"Geckodriver可执行文件必须位于PATH中" [英] Python 3.5 - "Geckodriver executable needs to be in PATH"

查看:182
本文介绍了Python 3.5-"Geckodriver可执行文件必须位于PATH中"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将geckodriver.exe添加到了PATH中,如您在此图像上看到的 之后,我重新启动了计算机.但是错误仍然出现.

I added geckodriver.exe into PATH as you can see on this image and i restarted my computer after. But the error still show up.

这是我的代码:

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://stackoverflow.com')

关于我做错了什么的线索吗?

Do you have clues about what I did wrong ?

推荐答案

我在您的代码块中看不到任何重大错误. 在使用Selenium 3.4.3,geckodriver v0.17.0,带有Python 3.6.1的Mozilla Firefox 53.0时,您可以考虑下载geckodriver并将其保存在计算机中的任何位置,并通过executable_path配置geckodriver的绝对路径.

I don't see any significant error in your code block. While working with Selenium 3.4.3, geckodriver v0.17.0, Mozilla Firefox 53.0 with Python 3.6.1 you can consider downloading the geckodriver and save it anywhere in your machine and configuring the absolute path of the geckodriver through executable_path.

要注意的是,当前的Selenium-Python绑定对于geckodriver来说是不稳定的,并且看起来是特定于体系结构的.您可以找到github 讨论

It is to be noted that the current Selenium-Python binding is unstable with geckodriver and looks to be Architecture specific. You can find the github discussion and merge here. So you may additionally need to pass the absolute path of the firefox binary as firefox_binary argument while initializing the webdriver

这是您自己的代码块,在我的末端执行得很好:

Here is your own code block which executes well at my end:

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

binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
driver.get('https://stackoverflow.com')

这篇关于Python 3.5-"Geckodriver可执行文件必须位于PATH中"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆