🚀 We are hiring! See open positions

Selenium: geckodriver executable needs to be in PATH?

by Bernardas Alisauskas May 29, 2023 1 min read

Selenium is a popular web browser automation library used for web scraping. To run, however, Selenium needs special web browser executables called drivers. For example, to run Firefox web browser Selenium needs geckodriver to be installed. Without it a generic exception will be raised:

text
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

This can also mean that the geckodriver is installed but Selenium can't find it. To fix this the geckodriver location should be added to the PATH environment variable:

shell
$ export PATH=$PATH:/location/where/geckodriver/is/

Alternatively, we can specify the driver directly in the Selenium initiation code:

python
from selenium import webdriver
driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
driver.get('https://scrapfly.io/')
Scale Your Web Scraping
Anti-bot bypass, browser rendering, and rotating proxies — all in one API. Start with 1,000 free credits.
No credit card required 1,000 free API credits Anti-bot bypass included
Not ready? Get our newsletter instead.