Markus
Markus

Reputation: 341

Why can't selenium find the chrome driver?

I am following a tutorial on using selenium and python to make a web scraper for twitter, and I ran into this error.

File "C:\Python34\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "C:\Python34\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: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

I went to the website specified in the error and downloaded the driver. Then I added it to path by going to System Properties > Advanced > Environment Variables > Path > New and added the exe file to path. I tried again and i still got the error.

Upvotes: 0

Views: 7423

Answers (2)

Davide Patti
Davide Patti

Reputation: 3461

If you take a look to your exception:

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

At the indicated url, you can see the Getting started with ChromeDriver on Desktop (Windows, Mac, Linux).

Where there is written:

Any of these steps should do the trick:

  1. include the ChromeDriver location in your PATH environment variable
  2. (Java only) specify its location via the webdriver.chrome.driver system property (see sample below)
  3. (Python only) include the path to ChromeDriver when instantiating webdriver.Chrome (see sample below)

If you are not able to include your ChromeDriver location in your PATH environment variable, you could try with the third one option:

import time
from selenium import webdriver

driver = webdriver.Chrome('/path/to/chromedriver')  # Optional argument, if not specified will search path.
driver.get('http://www.google.com');

Upvotes: 3

thebadguy
thebadguy

Reputation: 2140

Another way is download and uzip chromedriver and put 'chromedriver.exe' in C:\Python27\Scripts and then you need not to provide the path of driver, just

driver= webdriver.Chrome()

will work

Upvotes: 2

Related Questions