我正在通過「使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