Python + Browser with Mac: Error - 'chromedriver' executable needs to be in PATH
Asked Answered
P

3

18

I did the following but came across the error:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

from splinter import Browser

browser = Browser('chrome')

How can I go about resolving the issue using Mac?

Thank you in advance and will be sure to upvote/accept answer!

Phlyctena answered 20/4, 2017 at 20:7 Comment(1)
read this: splinter.readthedocs.io/en/latest/drivers/…Hobo
H
49

The easiest way to resolve this is on a Mac is to:

brew install --cask chromedriver

Splinter and similar frameworks for browser automation rely on external modules being installed and callable in PATH.

Edit: chromedriver migrated from homebrew/core to homebrew/cask

Highkeyed answered 21/4, 2017 at 3:28 Comment(7)
omg people have no idea this thing exist, I read forums with 100s of comments.Comedietta
seriously, if I could vote up your answer a million times, I wouldPalmation
Thank you so much, I tried all possibilities and they didn't work out but this did!Zabrze
So you're saying 'homebrew' does a "proper" install of modules than say PIP? It actually updates the PATH, etc? Wow.Sedentary
brew cask install chromedriverPip
This solution only worked for me when I entered the following command: brew install --cask chromedriver. So "cask" must be an option with "--". Thank you for the solution :-).Vannie
Please update to the new syntax: brew install --cask chromedriverDisulfiram
P
10

brew cask install chromedriver

The current working command to install chromedriver from brew, since the previously accepted answer has been outdated unfortunately.

This then needs to be paired with your selinium code :

chrome_path = r'/usr/local/bin/chromedriver' #path from 'which chromedriver'
driver = webdriver.Chrome(executable_path=chrome_path)

or 

import os 

driver = webdriver.Chrome(executable_path=os.popen('which chromedriver').read().strip())

Note: you may also need to do : brew cask install google-chrome

or

brew install --cask chromedriver

depending on your version of brew.

Pip answered 11/2, 2019 at 21:33 Comment(1)
Please update to the new syntax: brew install --cask chromedriverDisulfiram
K
0

Follow these three steps and you are all set !!!

  1. Change the permission of the exe file to read/write for the user you are using to execute the file.

  2. Check the version of the driver is same as that of your browser

  3. Also don't give .exe in the python path(just provide upto the chromedriver in the path)

example:

driver = webdriver.Chrome(executable_path="/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/chrome/chromedriver")
Kinnikinnick answered 26/9, 2020 at 3:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.