Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 368
Jo Ko Avatar asked Apr 20 '17 20:04

Jo Ko


2 Answers

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

brew cask install 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

like image 72
brennan Avatar answered Sep 23 '22 14:09

brennan


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.

like image 36
user2589273 Avatar answered Sep 20 '22 14:09

user2589273