0

I have the most up to date firefox browser and selenium installed. I tried running the following code:

from selenium import webdriver

browser = webdriver.Firefox()

...and received the following error:

Traceback (most recent call last):
  File "C:\Users\alisy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\alisy\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\alisy\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 992, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\alisy\AppData\Local\Programs\Python\Python36-32\download2.py", line 3, in <module>
    browser = webdriver.Firefox()
  File "C:\Users\alisy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 152, in __init__
    self.service.start()
  File "C:\Users\alisy\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, 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 downloaded geckodriver and specified the location in PATH (and then restarted my laptop). Did the same for firefox. It made no difference. What should I do?

rahlf23
  • 8,869
  • 4
  • 24
  • 54
MAS
  • 1
  • 1
  • 1
  • Is the driver in your current working directory? You can check with `os.listdir(os.getcwd())` – rahlf23 Mar 29 '18 at 19:55
  • 1
    Possible duplicate of [selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH error with chrome](https://stackoverflow.com/questions/46085270/selenium-common-exceptions-webdriverexception-message-chromedriver-executabl) – undetected Selenium Mar 29 '18 at 20:00
  • show how you specified the location in your PATH – Corey Goldberg Mar 30 '18 at 19:46

1 Answers1

0

This line of code solves the problem for me

driver=webdriver.Firefox(executable_path="c:/drivers/geckodriver.exe")
Amado Saladino
  • 2,114
  • 23
  • 25