Skip to content

Selenium using Python - Geckodriver executable needs to be in PATH

If you are using Selenium with the Firefox web browser and you see the error message "Geckodriver executable needs to be in PATH," it means that the Selenium Python library cannot find the geckodriver executable on your system. geckodriver is the executable that allows Selenium to interact with the Firefox browser.

To fix this error, you will need to download the geckodriver executable and add it to your system's PATH. You can download geckodriver from the following link:

https://github.com/mozilla/geckodriver/releases

Select the version of geckodriver that is compatible with your version of Firefox and your operating system, and download the executable.

Once you have downloaded geckodriver, you will need to add it to your system's PATH. On Windows, you can do this by adding the directory containing the geckodriver executable to your PATH environment variable. For example, in Command Prompt:

cmd
setx PATH "%PATH%;C:\path\to\geckodriver\dir"

On macOS or Linux, you can add geckodriver to your PATH by adding the following line to your .bashrc or .bash_profile file:

Add geckodriver to system's PATH

bash
export PATH=$PATH:/path/to/directory/containing/geckodriver

Replace /path/to/directory/containing/geckodriver with the actual path to the folder containing the geckodriver executable on your system.

Note: Starting with Selenium 4.6, Selenium Manager automatically downloads and manages geckodriver, so manual PATH configuration is often no longer required.

Once you have added geckodriver to your PATH, you should be able to use Selenium with Firefox without seeing the "Geckodriver executable needs to be in PATH" error.

Dual-run preview — compare with live Symfony routes.