1

I'm attempting to use Selenium with Python on a Mac.

from selenium import webdriver  
browser = webdriver.Firefox()

I get these errors:

FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver' During handling of the above exception, another exception occurred: selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

I've tried a number of different solutions, including altering my $PATH to add the location geckodriver is installed (see here), and placing the geckodriver executable file in usr/local/bin, per the documentation on Pypi.python.org for my version of Selenium (3.0.2).

$PATH now includes the path to where geckodriver is, but I continue to get the above errors. Any ideas?

I'm running Python 3.5.

Community
  • 1
  • 1
  • Have you reloaded your bash session after adding the location of geckodriver to your path? Can you share what is displayed when you `echo $PATH` – Lucas Tierney Jan 03 '17 at 01:54
  • This is what is displayed: `/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin` . Also reloaded my terminal session. – friendlyman23 Jan 03 '17 at 02:32
  • 1
    And what happens if you try to run `geckodriver` from the terminal? You should see something like this if it finds it `1483412667814 geckodriver INFO Listening on 127.0.0.1:4444` – Lucas Tierney Jan 03 '17 at 03:04
  • Here's what I got: `1483414605939 geckodriver INFO Listening on 127.0.0.1:4444` – friendlyman23 Jan 03 '17 at 03:37
  • Hmm, not sure then. It should be able to find it if you can run it from the terminal. Try adding the `executable_path` option `webdriver.Firefox(executable_path="/path/to/your/geckodriver")` – Lucas Tierney Jan 03 '17 at 13:25
  • @LucasTierney that worked. Wish there was some way around it. Thanks for help. – friendlyman23 Jan 03 '17 at 14:56
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/132211/discussion-between-friendlyman23-and-lucas-tierney). – friendlyman23 Jan 03 '17 at 15:08
  • I had the same problem trying to 'build' from within SublimeText and the comment from @LucasTierney above ( `webdriver.Firefox(executable_path="/path/to/your/geckodriver")` ) fixed it for me. Thanks! Maybe this could be answer and we could upvote? – drstevok Apr 28 '18 at 20:47
  • @drstevok it was an answer but got converted to a comment – Lucas Tierney May 09 '18 at 16:16

0 Answers0