How to put geckodriver into PATH?

48,818

Solution 1

I faced this same problem and here's how I fixed it:

  1. Download the geckodriver from here
  2. Extract and unzip and move the geckodriver file to /usr/local/bin/ directory
  3. Run python program with selenium Firefox webdriver.

Solution 2

You will need to add the binary to your $PATH. You can do this by:

export PATH=$PATH:/path/to/geckodriver

Solution 3

"I have geckodriver copied everywhere in my Python folders." Ensure the geckodriver executable is found in one of the paths when you run:

import sys
print sys.path

And the problem should be resolved.

Share:
48,818
Matthew Garcia
Author by

Matthew Garcia

Updated on July 30, 2022

Comments

  • Matthew Garcia
    Matthew Garcia over 1 year

    I'm on OS Sierra and i'm running Python 3.5.2. I have selenium installed and i'm following a book called "Automate the Boring Tasks With Python"

    My code is

    from selenium import webdriver
    >>> browser = webdriver.Firefox()
    

    I keep receiving the error

    Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
    FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "<pyshell#1>", line 1, in <module>
    browser = webdriver.Firefox()
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
    self.service.start()
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/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. 
    

    I have searched far and wide for solutions to my issue. Many people have the same issue.. but none of the solutions are working. I have geckodriver copied everywhere in my Python folders. I've tried using terminal and I have tried specifying the path within the code and it still gives me errors. I hope somebody can help me. I'm sorry if this is in the wrong format, I don't know what i'm doing.

  • Matthew Garcia
    Matthew Garcia over 7 years
    I have done this and i'm still getting the same issue.
  • Admin
    Admin over 7 years
    What are the file permissions on your geckodriver file?
  • Matthew Garcia
    Matthew Garcia over 7 years
    It's set to read and write for everyone. I also have my security set to open apps downloaded from anywhere.
  • Admin
    Admin over 7 years
    @MatthewGarcia cool. It needs to be an executable else it will never run. Can you run chmod ugo+x geckodriver please?
  • Admin
    Admin over 7 years
    @MatthewGarcia still the same error?