Tag Archives: Message: ‘geckodriver’ executable needs to be in PATH.

Message: ‘geckodriver’ executable needs to be in PATH. [Solved]

Problem Description:

Execute the following code

# coding=utf-8
from selenium import webdriver

driver = webdriver.Firefox()
driver.maximize_window()
driver.implicitly_wait(2)

driver.get('https://www.baidu.com')
try:
    driver.find_element_by_id('kw')
    print('test pass: ID found')
except Exception as e:
    print('Exception found', format(e))

driver.quit()

Error:

Traceback (most recent call last):
File “E:/PythonSelenium/CSDN/004id.py”, line 4, in <module>
driver = webdriver.Firefox()
File “E:\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py”, line 142, in __init__
self.service.start()
File “E:\Python35\lib\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.

Reason:

Message: ‘geckodriver’ executable needs to be in PATH.

Solution:

(1) test environment: Selenium 3.4.0 Firefox 56.0 Python3.5.2

(2) Download the corresponding driver for Firefox, portal https://github.com/mozilla/geckodriver/releases combined with the version of my browser need to download V 0.19.0

(3) Unzip the file to get the geckodriver.exe file and place it in the home directory. After re-running found that the problem has been solved.

Note: Pay attention to Firefox, Python environment variable settings.