2017-10-07 54 views
-1

所以,我想與Python的硒工作,但每次我得到一個錯誤。蟒蛇'geckodriver需要在你的路徑'錯誤

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. 

我試圖運行此代碼

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

,但它只是口口聲聲說這一點。有沒有辦法把它放在所有目錄中? 我該如何解決第一個錯誤?

+1

的[使用Python硒 - Geckodriver可執行文件需要在PATH]可能的複製(https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to -be-in-path) – Andersson

+0

這些答案仍然不工作,我不能複製和過去我的geckodriver –

回答

1

您的問題是,您將geckodriver添加到路徑,而不是包含geckodriver的文件夾添加到路徑。使用下面

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

thnx但我已經修復它,我需要把geckodriver放在/ usr/bin / –