I am using Ubuntu 16.04.1 LTS. Executing python -V returns Python 2.7.12. I am building a virtualenv off of that so as to install the Selenium package into it via:

pip install -upgrade selenium

But when doing a trial run with the following python script:

from selenium import webdriver
browser = webdriver.Firefox()

it results this error:

 Traceback (most recent call last):
   File "/home/myuser/bin/selenium-experiment.py", line 2, in <module>
     browser = webdriver.Firefox()
   File "/home/myuser/python_virtualenv/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
   File "/home/myuser/python_virtualenv/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 71, in start
     os.path.basename(self.path), self.start_error_message)
 selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

 Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7f782c1caa50>> ignored

Since geckodriver is an executable, I concluded that it should be provided by the installation of the selenium package via pip or at least error out with some message stating what I need to do next. Apparently not, so I dug further: I thought that perhaps Ubuntu should have a package that provides the geckodriver executable so I used apt-file search geckodriver to search for it and found no results.

Where do I get this geckodriver executable?

  • Get it from github.com/mozilla/geckodriver.
    – edwinksl
    Nov 20 '16 at 3:35
  • 1
    Why can't pip install command for selenium just install whatever selenium depends upon?
    – bgoodr
    Nov 20 '16 at 3:43
  • 3
    That's a question for maintainers of Selenium and geckodriver. All I can say is you do have to get geckodriver from somewhere (GitHub in this case) other than PyPI.
    – edwinksl
    Nov 20 '16 at 3:44

Find the latest release for your OS.

Extract it, and copy geckodriver to /usr/local/bin -- so if v0.11.1 was the most recent version, and you were on 64bit linux, you'd do this:

export GECKO_DRIVER_VERSION='v0.24.0'
wget https://github.com/mozilla/geckodriver/releases/download/$GECKO_DRIVER_VERSION/geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
tar -xvzf geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
rm geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
chmod +x geckodriver
cp geckodriver /usr/local/bin/

Now your trial run should work.

  • 2
    Same method applies for chromedriver as well. :) Dec 27 '16 at 12:07
  • 1
    chromedriver can now be installed with apt-get install -qqy chromedriver.
    – Rakaim
    Jun 4 '18 at 21:20
  • If this doesn't work, copy the gecko driver to /usr/bin. This worked for me Jun 13 '19 at 8:29
  • cp geckodriver /usr/local/bin/ needs SUDO permission. So Sudo it. Oct 24 '19 at 8:55

Ubuntu 16.04+:

sudo apt-get install firefox-geckodriver

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.