我正在通过“使Python自动化枯燥的东西”,并运行带有运行OS X v.10.9.5的Mac的Python 3.6。我的Firefox版本是50.0。在Mac上使用Python和Firefox的selenium webdriver的问题
每当我输入(每在第11章中的说明):
>>> from selenium import webdriver
>>> browser = webdriver.Firefox()
我收到以下错误:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
browser = webdriver.Firefox()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 140, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
我已搜查在本网站和其他这个错误,但最提供的解决方案是特定于Windows的(包括下面评论中引用的帖子),或者在应用时似乎不适用于我的Mac机器。
我应该做什么的建议?
请记住,我是一个总新手,所以不熟悉终端。预先感谢您的帮助。
的[使用Python硒可能的复制 - Geckodriver可执行文件需要在PATH](http://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path) – martianwars
正如我在我的帖子中提到的,我没有检查这个网站上的主题以前的帖子,并尝试在帖子上提供您的参考解决方案,但没有与他们取得任何成功。 引用的帖子来自Windows用户,而我正在使用Mac。此外,该线索中的发布说明明确要求海报发布答案,而不是澄清要求或其他问题。 – Oligarch
您是否尝试过其中一条评论? “在Mac上:'brew install geckodriver'”? – martianwars