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?
33 Answers
Here are the steps:
Go to the geckodriver releases page. Find the latest version of the driver for your platform and download it. For example:
wgetExtract the file with:
tar -xvzf geckodriver*Make it executable:
chmod +x geckodriverAdd 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.
9Manual 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
geckodriverbinary to/usr/local/binor 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