我已经阅读了以前关于这个主题的问题,并尝试遵循这些建议,但我仍然会出错。在终点站,我跑了

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]

最佳答案

你可以把硒降低到
PIP安装硒==2.53.6
这解决了我的问题

关于python - geckodriver可执行文件需要在路径中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40048940/

10-12 20:22
查看更多