0

Trying to run the following script to go to this website and click a link to export a csv.

from selenium import webdriver
driver=webdriver.Firefox()
driver.get("https://www.draftkings.com/contest/gamecenter/46877680")
elem1 = driver.find_element_by_link_text("Export Lineups to CSV")
elem1.click()

I get the following error and can't find a geckodriver. I pip installed selenium. I got this from an older video and I currently run Python 3.6 so that is probably part of the problem as well. Where am I going wrong?

Traceback (most recent call last): File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start stdout=self.log_file, stderr=self.log_file) File "C:\Program Files\Python36\lib\subprocess.py", line 707, in init restore_signals, start_new_session) File "C:\Program Files\Python36\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/mike/Desktop/Lineup1.py", line 2, in driver=webdriver.Firefox() File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 144, in init self.service.start() File "C:\Program Files\Python36\lib\site-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.

2
  • The first thing you should do when you get an error message you don't understand is to google it. That will generally find you answers that you can at least start with. Commented Oct 19, 2017 at 5:46
  • That’s how I got to stack overflow Jeff.. Commented Oct 19, 2017 at 13:33

2 Answers 2

1

Download the geckodriver and Drag and Drop the geckodriver.exe file to the project root folder. In this way, there is no need of adding the geckodriver path in your code and again try to execute the code. No error will come

Sign up to request clarification or add additional context in comments.

Comments

-1

Actually, The Selenium client bindings try to locate the geckodriver executable from the system PATH. You will need to add the directory containing the executable to the system path. On Unix systems you can do the following to append it to your system’s search path if you’re using a bash-compatible shell:

export PATH=$PATH:/path/to/directory/of/executable/downloaded/in/previous/step

On Windows, you will need to update the Path system variable to add the full directory path to the executable geckodriver manually or command line(don't forget to restart your system after adding executable geckodriver into system PATH to take effect). The principle is the same as on Unix.

and then try using the following

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('path/to/installed firefox binary')
browser = webdriver.Firefox(firefox_binary=binary)

References,

https://github.com/mozilla/geckodriver/releases

https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver

3 Comments

I stumbled across this earlier Neel, thank you for the response. I am not sure how to update the Path system variable to add the full directory path to the executable geckodriver manually or command line(don't forget to restart your system after adding executable geckodriver into system PATH to take effect).
I went to github.com/mozilla/geckodriver/releases and downloaded the gecko.exe. What does it mean by being in the file path? i currently just have the lineup.py script on my desktop
ok, i got it. It requires i log in every time though. which is going to be another headache but atleast it opens. The other thing is i don't think its clicking the link i have requested.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.