What to Do When 'geckodriver' Executable Needs to Be in PATH in Ubuntu's Selenium

Linux
2017-02-03 09:40 (8 years ago) ytyng

Trying to run Selenium on Ubuntu from Python

Traceback (most recent call last):
... omitted ...
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 140, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 81, 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 0x7fd28405b350>> ignored

If that happens,

wget https://github.com/mozilla/geckodriver/releases/download/v0.14.0/geckodriver-v0.14.0-linux64.tar.gz
tar -zxvf geckodriver-v0.14.0-linux64.tar.gz
sudo mv geckodriver /usr/local/bin/

You can check the latest release here: https://github.com/mozilla/geckodriver/releases

By the way, the constructor of webdriver.Firefox is as follows:

    def __init__(self, firefox_profile=None, firefox_binary=None,
                 timeout=30, capabilities=None, proxy=None,
                 executable_path="geckodriver", firefox_options=None,
                 log_path="geckodriver.log"):
        """Starts a new local session of Firefox.

So, it seems you can also specify the full path of geckodriver in the executable_path parameter.

Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Archive

2025
2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011