0

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.

Markus
  • 331
  • 2
  • 4
  • 13
  • 1
    What exactly does this mean: "added the exe file to path"? – SiKing Oct 26 '17 at 22:18
  • @SiKing I added a system variable to path and linked it to the chromedriver exe file I [downloaded](https://sites.google.com/a/chromium.org/chromedriver/home). – Markus Oct 26 '17 at 22:41
  • What does your path look like? Post the result of `echo %PATH%`. – SiKing Oct 26 '17 at 22:56
  • Possible duplicate of [Error message: "'chromedriver' executable needs to be available in the path"](https://stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path) – JeffC Oct 26 '17 at 23:25

2 Answers2

3

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');
Davide Patti
  • 3,391
  • 2
  • 18
  • 20
2

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

thebadguy
  • 2,092
  • 1
  • 22
  • 31