python selenium'geckodriver需要在你的路径'错误

时间:2017-10-07 20:13:02

标签: python-3.x selenium

所以,我想用python与selenium一起工作,但每次我都会收到错误。

pom.xml

我试图运行此代码

    Traceback (most recent call last):
  File "/home/lario/.local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1282, 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 "a.py", line 7, in <module>
    browser = webdriver.Firefox(firefox_binary=binary)
  File "/home/lario/.local/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 144, in __init__
    self.service.start()
  File "/home/lario/.local/lib/python3.5/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. 

但它一直在说这个。有没有办法把它放在所有目录中?   我如何解决第一个错误?

1 个答案:

答案 0 :(得分:1)

您的问题是您要将geckodriver添加到路径而不是路径中包含geckodriver的文件夹。使用以下

export PATH=$PATH:/home/lario/Desktop/workstation/