If you are having some confusion about the “Message: ‘geckodriver’ executable needs to be in path” error in Python, read our article below to get your solution to the problem.
Why does the problem occur?
Gecko Driver-a connecting link to the Firefox browser for your scripts in Selenium. It is essential for Selenium Web Driver if you want to automate by Firefox browser. As a result, you will always receive “WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH” error when missing to declare GeckoDriverManager or add the executable path to the installation file.
Code:
from selenium import webdriver driver = webdriver.Firefox(executable_path=GeckoDriverManager().install()) driver.get("https://learnshareit.com")
Error:
WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
There are two common solutions to fix the problem. Let’s see.
Solutions to fix error “Message: ‘geckodriver’ executable needs to be in path.”
Solution 1: Handle by webdriver-manager
WebDriverManager is an open-source Java library that carries out the management of the drivers required by Selenium WebDriver, such as ChromeDriver, GeckoDriver, EdgeChromiumDriver, etc.
To manage GeckoDriver, you have to install WebDriverManager and indirectly control GeckoDriver. The process is displayed below.
- Step 1: Install webdriver-manage with the command:
pip install webdriver-manager
- Step 2: Import GeckoDriverManager
- Step 3: Pass GeckoDriverManager installation as the executable path
Selenium 3:
pip install webdriver-manager
from selenium import webdriver from webdriver_manager.firefox import GeckoDriverManager driver = webdriver.Firefox(executable_path=GeckoDriverManager().install()) driver.get("https://learnshareit.com")
Selenium 4:
pip install webdriver-manager
from selenium import webdriver from selenium.webdriver.firefox.service import Service as FirefoxService from webdriver_manager.firefox import GeckoDriverManager driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()) driver.get("https://learnshareit.com")
After running this code, your Firefox browser will automatically open our website, try and see the result.
Solution 2: Add the path to “geckodriver.exe”
Another solution to the problem is adding the path of the executable software – geckodriver.exe to the parameter executable_path
directly. You should download the latest version of the software, then unzip it and link to the installation file.
- Step 1: Download Gecko Driver here
- Step 2: Copy the path to “geckodriver.exe” and pass it as the executable path
Code:
from selenium import webdriver driver = webdriver.Firefox(executable_path=r'\path\geckodriver.exe') driver.get("https://learnshareit.com")
Summary
Well done. We have shown you how to solve the error “message: ‘geckodriver’ executable needs to be in path” and execute the code, which automatically opens the browser and links to our website. Now you can create a new one of your own. We hope that our article is helpful to you. If you have any questions, leave us your comments, and do not forget to visit our website for more information.
Maybe you are interested:
- ModuleNotFoundError: No module named ‘requests’
- ModuleNotFoundError: No module named ‘scipy’ in Python
- ModuleNotFoundError: No module named ‘skbuild’ in Python

My name is Robert Collier. I graduated in IT at HUST university. My interest is learning programming languages; my strengths are Python, C, C++, and Machine Learning/Deep Learning/NLP. I will share all the knowledge I have through my articles. Hope you like them.
Name of the university: HUST
Major: IT
Programming Languages: Python, C, C++, Machine Learning/Deep Learning/NLP