How to install geckodriver in Ubuntu?

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:

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

3

3 Answers

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 
  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.

9

Manual steps to install geckodriver on Ubuntu:

  • visit
  • 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 )
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"
3

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

## Geckodriver
wget
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
unzip chromedriver_linux64.zip
sudo chmod +x chromedriver
sudo mv chromedriver /usr/bin/
rm chromedriver_linux64.zip
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like