【发布时间】:2016-10-14 17:33:38
【问题描述】:
我已阅读有关此主题的先前问题并尝试遵循建议,但我仍然遇到错误。在终端上,我跑了
export PATH=$PATH:/Users/Conger/Documents/geckodriver-0.8.0-OSX
我也试过
export PATH=$PATH:/Users/Conger/Documents/geckodriver
当我运行以下 Python 代码时
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/Users/Conger/Documents/Firefox.app'
driver = webdriver.Firefox(capabilities=firefox_capabilities)
我仍然收到以下错误
Python - testwebscrap.py:8
Traceback (most recent call last):
File "/Users/Conger/Documents/Python/Crash_Course/testwebscrap.py", line 11, in <module>
driver = webdriver.Firefox(capabilities=firefox_capabilities)
File "/Users/Conger/miniconda2/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/Users/Conger/miniconda2/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x1006df6d0>> ignored
[Finished in 0.194s]
【问题讨论】:
-
设法解决了这个问题!我没有创建新路径,而是将 geckodriver 文件添加到我的 bash_profile 中列出的路径中。立即工作!
标签: python