Reputation: 1
File "helloselenium.py", line 2, in <module>
driver = webdriver.Firefox(executable_path=r'\usr\local\bin\geckodriver')
File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 144, in __init__
self.service.start()
File "/Library/Python/2.7/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: '\usr\local\bin\geckodriver' executable needs to be in PATH.
Upvotes: 0
Views: 170
Reputation: 58
I had a similar issue recently as I am a new MAC convert. There’s a few options. First you can add the driver location to your path as explained above. To do this you can open a terminal and use the following to update it: sudo nano /etc/paths
This will allow you to add the path. Also it will display the other paths. Confirm the driver is in one of those.
If modifying your path isn’t something you are comfortable with, you can always use Homebrew to install geckodriver. This is well documented online. As an aside, when installing geckodriver via Homebrew, sometimes you need to install twice as it will not properly link the first time.
Good luck. Also this same process works for chromedriver should you decide to add Chrome coverage in the future.
Upvotes: 0
Reputation: 458
Selenium client tries to locate the geckodriver executable from the system PATH. You will need to add the directory containing the executable to the system path.
export PATH=$PATH:/path/to/directory/of/executable/
now you can change your code to this:
from selenium import webdriver
browser = webdriver.Firefox()
Upvotes: 1
Reputation: 60
You need to add the driver to your PATH, read here How to put geckodriver into PATH? Alternatively you can also hardcode the full path to wherever the geko driver is:
path = "put the full path here"
driver = webdriver.Firefox(path)
Upvotes: 0