Mac上的Python中的Selenium - Geckodriver可执行文件需要在PATH中 [英] Selenium in Python on Mac - Geckodriver executable needs to be in PATH

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

问题描述

大约两个月前,我是编程新手,开始使用Python,并且正在使用Sweigart的使用Python文本自动化烦人的东西。我使用的是Spyder 3,并且已经安装了硒模块和Firefox浏览器。我在python文件中使用了以下代码:

pre $ from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://inventwithpython.com')

我得到这个错误:

 消息:'geckodriver'可执行文件需要在PATH中。 

我已经下载了geckodriver.exe,除了进入终端并使用



$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $'奇怪的是,如果我进入终端并键入python,然后把代码放入,它的工作原理,但不是当我在Spyder中运行文件。我需要把geckodriver.exe文件放在哪里?我已经尝试把它放在各种文件夹(与python文件相同的文件夹,与webdriver文件相同的文件夹,在用户bin,等等),但我得到了相同的错误



我看过类似的问题,但似乎无法找到有效的东西。我也试过使用Chrome,但是我得到了和chromedriver一样的错误。

 哪个geckodriver 

产生 / usr / local / bin / geckodriver



我也是在Mac上,所以文件路径对于我来说比在Windows上困难一些。

解决方案

解决方案:我把geckodriver exe放在/ Users / sethkillian / anaconda / bin中,现在它可以在Spyder上运行,没有问题。感谢您的帮助!


I'm new to programming and started with Python about 2 months ago and am going over Sweigart's Automate the Boring Stuff with Python text. I'm using Spyder 3 and already installed the selenium module and the Firefox browser. I used the following code in python file

from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://inventwithpython.com')

I get this error:

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

I've downloaded geckodriver.exe in addition to going into terminal and installing it using

brew install geckodriver

Oddly enough, if I go into terminal and type "python" and then put the code in, it works, but not when I run the file in Spyder. Where do I need to put the geckodriver.exe file for it to work? I've tried putting it in various folders (same folder as the python file, same folder as the webdriver file, in the user bin, and so on) but I get the same error

I've looked at similar questions but can't seem to find something that works. I've also tried with Chrome but I get the same error but with chromedriver.

which geckodriver

yields /usr/local/bin/geckodriver

I'm also on a Mac, so file paths are a little more difficult for me than on windows.

解决方案

SOLVED: I placed the geckodriver exe in /Users/sethkillian/anaconda/bin and now it works from Spyder with no problem. Thanks for the help!

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

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