118

I use Selenium in Python, I tried to run the webdriver function:

default_browser = webdriver.Firefox()

This Exception:

WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

geckodriver in this site: https://github.com/mozilla/geckodriver

But how to install in Ubuntu 16.04 and can I fix this?

uvasal
  • 513
mySun
  • 2,021

6 Answers6

171

Here are the steps:

  1. Go to the geckodriver releases page. Find the latest version of the driver for your platform and download it. For example:

    wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
    
  2. Extract the file with:

    tar -xvzf geckodriver*
    
  3. Make it executable:

    chmod +x geckodriver
    
  4. Add the driver to your PATH so other tools can find it:

    export PATH=$PATH:/path-to-extracted-file/.
    

There are many ways to do this that will work. The above works for me on Ubuntu 16.10 64-bit.

Addison
  • 306
  • 4
  • 13
Steven Stip
  • 1,920
32

Manual steps to install geckodriver on Ubuntu:

  • visit https://github.com/mozilla/geckodriver/releases
  • download the latest version of "geckodriver-vX.XX.X-linux64.tar.gz"
  • unarchive the tarball (tar -xvzf geckodriver-vX.XX.X-linux64.tar.gz)
  • give executable permissions to geckodriver (chmod +x geckodriver)
  • move the geckodriver binary to /usr/local/bin or any location on your system PATH.

Script to install geckodriver on Ubuntu:

#!/bin/bash

INSTALL_DIR="/usr/local/bin"

json=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest) url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux64") and endswith("gz"))') curl -s -L "$url" | tar -xz chmod +x geckodriver sudo mv geckodriver "$INSTALL_DIR" echo "installed geckodriver binary in $INSTALL_DIR"

24

Webdriver installation (silent mode) that can be used in sysadmin scripts (bash/ansible).

## Geckodriver
wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz
sudo sh -c 'tar -x geckodriver -zf geckodriver-v0.23.0-linux64.tar.gz -O > /usr/bin/geckodriver'
sudo chmod +x /usr/bin/geckodriver
rm geckodriver-v0.23.0-linux64.tar.gz

## Chromedriver
wget https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo chmod +x chromedriver
sudo mv chromedriver /usr/bin/
rm chromedriver_linux64.zip
Sandeep
  • 590
  • 4
  • 5
6

On Ubuntu 22.04, it seems that geckodriver is now installed when you install Firefox:

$ sudo apt install firefox 

It seems that the old firefox-geckodriver package has been dropped.

4

If you use the command line pre ubuntu 2.04:

sudo apt-get install firefox-geckodriver

Thanks to the comment of @countermeasure:

apparently installing firefox will also install gecko driver

sudo apt install firefox 
1

There are essentially three steps:

  1. download a release from github
  2. unzip into the right directory, namely usr/local/bin (can be merged into one line!)
  3. set executable permissions. These steps should work for any Linux distribution (worked on my Debian 10). Here is the shell code:
wget https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz
sudo tar -xzvf geckodriver*tar.gz -C /usr/local/bin
sudo chmod +x /usr/local/bin/geckodriver

As for newest versions of Ubuntu, it can be installed with sudo apt-get install firefox. Older versions accept sudo apt-get install firefox-geckodriver.

Package firefox-geckodriver is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  firefox