0

I am trying to run a script with Selenium and keep getting the error message:

FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver': 'geckodriver'

Thus far, I have attempted to remedy it by:

  1. Installing geckodriver
  2. Attempting to follow the instructions here to the problem
  3. That didn't work, so I made sure there was a path to /usr/local/bin, where geckodriver was installed
  4. Still didn't work, so I moved geckodriver to the path laid out in the error message, which was "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py",
  5. Still didn't work, so I moved geckodriver to the same folder where the script is saved.

I've been Google searching and watching YouTube videos for a full day, and I've made no progress. Any help would be greatly appreciated.

EDIT:

Code is just the first script from the web scraping chapter in Automate the Boring Stuff:

from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://inventwithpython.com')
7edubs7
  • 15
  • 6
  • Would you be able to add the code from your python script where you load the Gecko driver? I remember having some issues with this a while back but don't remember exactly how I solved it. Thanks! – Steve Byrne Oct 24 '18 at 16:57
  • Read the error a bit more closely, and take it literally. It's not complaining about a file named `geckodriver`, it's complaining about a file named `'geckodriver': 'geckodriver'`. In other words, you've configured it such that you're giving it a key/value pair where it expects a filename. – Bryan Oakley Oct 24 '18 at 16:58
  • 1
    It would be helpful to see the code the produced the error message – killian95 Oct 24 '18 at 17:00
  • `usr/local/bin` and `/usr/local/bin` (note leading slash) are **not** the same thing! – SiKing Oct 24 '18 at 19:08
  • @SiKing that's what the original path was, i mistakenly left it out when writing it out here – 7edubs7 Oct 24 '18 at 19:32
  • @SteveByrne i updated the original post with it – 7edubs7 Oct 24 '18 at 19:40
  • @BryanOakley thanks. any suggestions on how to remedy that? – 7edubs7 Oct 24 '18 at 19:40
  • Using the code you posted, the newest gecko driver from: https://github.com/mozilla/geckodriver/releases (64 bit for me) and python 3.6.4 it worked! can you confirm you have the latest gecko driver in the same folder as your python script? – Steve Byrne Oct 24 '18 at 19:46
  • 1
    @SteveByrne re-downloaded it, put gecko driver in the same folder as the script, ran script, same error message. – 7edubs7 Oct 24 '18 at 19:57
  • You're still getting a file not found error? What OS are you using? (Windows, Mac, Linux?) and what python version? I assume you have firefox installed and updated too, correct? I got a similar error the first time I ran it because fire fox launched an updater instead of the web client. – Steve Byrne Oct 24 '18 at 19:59
  • Also, how are you running the script? If for example you run it from the command line, it's execution director is in System32 (on windows) no where your script is saved. – Steve Byrne Oct 24 '18 at 20:00
  • I am on a Mac running Python 3.6 getting the file not found error. Firefox is installed. I am running the script out of IDLE. I also have gecko driver in the folder located at /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ – 7edubs7 Oct 24 '18 at 20:05
  • Have you put the Gecko driver in: /usr/local/bin yet? – Steve Byrne Oct 24 '18 at 20:15
  • @SteveByrne the first thing i did to try to troubleshoot this! – 7edubs7 Oct 24 '18 at 20:17
  • In Python run: print(os.path.dirname(os.path.realpath(__file__))) and paste a copy of geckodriver.exe in that folder (make sure geckodriver.exe is the exact name, no alterations) – Steve Byrne Oct 24 '18 at 20:25
  • @SteveByrne did that, still same error. also, i believe exe is for windows only? – 7edubs7 Oct 24 '18 at 20:32
  • You're correct, exe is windows based only; I use linux/windows and forget what Mac uses sometimes :P Maybe see if you can access it from the terminal (See if you can run gecko from the terminal) and make sure you reboot your computer after any path changes (shouldn't need this but allot of times you do); not sure how much help I'll be but I'll try an help more later tonight; good luck! – Steve Byrne Oct 24 '18 at 20:37
  • 1
    @SteveByrne Thanks so much for trying to help. I really do appreciate it! – 7edubs7 Oct 24 '18 at 20:49

0 Answers0