21

I am having issues getting an instance of a Chrome browser from selenium in python. I'm using Windows 8. I have downloaded the chromedriver binary and added it to my path but I get the following error in Python:

selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.   

This error occurs for the following line:

driver = webdriver.Chrome(executable_path='path\to\chromedriver_win32_2.0')  
6
  • 1
    Have you read this yet?
    – John
    Commented Jul 2, 2013 at 22:21
  • 5
    Click on the work "this".
    – John
    Commented Jul 2, 2013 at 22:28
  • Oh dear that was stupid, couldn't see the link. Sorry, but I read it and it has no info about where Chrome is expected to be installed for Windows 8. Commented Jul 2, 2013 at 22:41
  • 1
    You need to download the chrome driver that is provided in the link, and make that available in the path.
    – Amey
    Commented Jul 2, 2013 at 23:14
  • Thank you for your response but if you read the question, I did that already. Commented Jul 3, 2013 at 0:54

8 Answers 8

32

Two ways to set it, you somehow mixed up.

  • Put the chromedriver.exe's path into PATH (on Windows), so your PATH setting is correct, but you need to call the default constructor.

    driver = webdriver.Chrome()

  • Specify the path in webdriver.Chrome(executable_path='some path'). Here you need the full path to the executable, not the directory.

    webdriver.Chrome(executable_path=r'C:\Users\HaranKumar\Downloads\chromedriver_win32_2.0\chromedriver.exe')

Choose either one you want.

1
  • 1
    for windows use double slash webdriver.Chrome(executable_path='C:\\drivers\\chromedriver.exe')
    – Kavan
    Commented Aug 16, 2015 at 15:07
2

Assuming that your path is correct, make sure that you include the chromedriver itself: chromedriver.exe

1
  • 2
    Having the file in PATH wasn't enough for me. Put it to `Python\Scripts`.
    – Qwerty
    Commented Aug 29, 2014 at 9:52
2

I used the following and it worked! Thanks!

driver = webdriver.Chrome(executable_path=r'C:\chromedriver.exe')
#put your own path between the ''
0
0

Even if you have chromedriver.exe in the PATH, its necessary to have chromedriver.exe in the folder where your executable scripts are present(atleast so is the case when it comes to python scripts)

0

for python(selenium) you will need:

from selenium import webdriver
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options

then put your chromedriver.exe path in. the "r" is just to prevent it from detecting the \ and causing errors in python

PATH = r"C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
options = webdriver.ChromeOptions()

you can now order the driver to get websites

driver.get('http://www.google.com')
0

Update 2021 For Python

I got Selenium to open my default Chrome browser with my profile using this:

options.add_argument("--user-data-dir=C:\\Users\\Sams\\AppData\\Local\\Google\\Chrome\\User Data")
options.add_argument('--profile-directory=Default')
  1. Go to: chrome://version/
  2. Look for your "Profile Path" profile path image
  3. Copy your Profile Path and replace "options.add_argument("--user-data-dir={YOUR PROFILE PATH}")"
  4. The second argument may also look different. Mine so happens to be "Default". For other it may be "Profile 1" or "Profile X" X being an incrementing number.
  5. Close all your Chrome browsers before running. Because the Chrome Driver cannot run an automated browser alongside the rest of your other tabs.

Here is my entire Selenium Config. Hopefully it helps someone.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.remote.webdriver import WebDriver
    

options = Options()
options.add_argument("--window-size=1920,1080")
options.add_argument("--log-level=3")
options.add_experimental_option('excludeSwitches', ['enable-logging'])


# The 2 arguments below will use your main browser. 
options.add_argument("--user-data-dir=C:\\Users\\Sams\\AppData\\Local\\Google\\Chrome\\User Data") # profile path (C)
options.add_argument('--profile-directory=Default')

options.headless = False # To show Chrome or not to show?
PATH = (r"C:\Users\Sams\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe") 

CHROMEDRIVER_PATH = PATH
driver = webdriver.Chrome(CHROMEDRIVER_PATH, options=options)
0

I recently ran into this error and I found three main solutions for this chromedriver not in path error

  1. download a library that does it - webdriver_manager or chromedriver_autoinstaller both work
  2. add it to path in your program
  3. add chromedriver executable to your system PATH
-1

Update 2016

The following solution works for me, with WebDriver 3.0.1, Chrome Driver 2.25.426923, Window 7

    System.setProperty("webdriver.chrome.driver","D:\\workspace\\chromedriver.exe");
    WebDriver driver;
    driver = new ChromeDriver();

*Note:

Not the answer you're looking for? Browse other questions tagged or ask your own question.