Error message: "'chromedriver' executable needs to be available in the path"

PythonSeleniumSelenium Chromedriver

Python Problem Overview


I am using selenium with python and have downloaded the chromedriver for my windows computer from this site: http://chromedriver.storage.googleapis.com/index.html?path=2.15/

After downloading the zip file, I unpacked the zip file to my downloads folder. Then I put the path to the executable binary (C:\Users\michael\Downloads\chromedriver_win32) into the Environment Variable "Path".

However, when I run the following code:

  from selenium import webdriver

  driver = webdriver.Chrome()

... I keep getting the following error message:

WebDriverException: Message: 'chromedriver' executable needs to be available in the path. Please look at     http://docs.seleniumhq.org/download/#thirdPartyDrivers and read up at http://code.google.com/p/selenium/wiki/ChromeDriver

But - as explained above - the executable is(!) in the path ... what is going on here?

Python Solutions


Solution 1 - Python

I see the discussions still talk about the old way of setting up chromedriver by downloading the binary and configuring the path manually.

This can be done automatically using webdriver-manager

pip install webdriver-manager

Now the above code in the question will work simply with below change,

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
 

The same can be used to set Firefox, Edge and ie binaries.

Solution 2 - Python

You can test if it actually is in the PATH, if you open a cmd and type in chromedriver (assuming your chromedriver executable is still named like this) and hit Enter. If Starting ChromeDriver 2.15.322448 is appearing, the PATH is set appropriately and there is something else going wrong.

Alternatively you can use a direct path to the chromedriver like this:

 driver = webdriver.Chrome('/path/to/chromedriver') 

So in your specific case:

 driver = webdriver.Chrome("C:/Users/michael/Downloads/chromedriver_win32/chromedriver.exe")

Solution 3 - Python

On Ubuntu:

sudo apt install chromium-chromedriver

On Debian:

sudo apt install chromium-driver

On macOS install Homebrew then do

brew install --cask chromedriver

Solution 4 - Python

For Linux and OSX

Step 1: Download chromedriver

# You can find more recent/older versions at http://chromedriver.storage.googleapis.com/
# Also make sure to pick the right driver, based on your Operating System
wget http://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_mac64.zip

For debian: wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip

Step 2: Add chromedriver to /usr/local/bin

unzip chromedriver_mac64.zip
sudo mv chromedriver /usr/local/bin
sudo chown root:root /usr/local/bin/chromedriver
sudo chmod +x /usr/local/bin/chromedriver

You should now be able to run

from selenium import webdriver

browser = webdriver.Chrome()
browser.get('http://localhost:8000')

without any issues

Solution 5 - Python

Same situation with pycharm community edition, so, as for cmd, you must restart your ide in order to reload path variables. Restart your ide and it should be fine.

Solution 6 - Python

We have to add path string, begin with the letter r before the string, for raw string. I tested this way, and it works.

driver = webdriver.Chrome(r"C:/Users/michael/Downloads/chromedriver_win32/chromedriver.exe")

Solution 7 - Python

According to the instruction, you need to include the path to ChromeDriver when instantiating webdriver.Chrome eg.:

driver = webdriver.Chrome('/path/to/chromedriver')

Solution 8 - Python

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

driver= webdriver.Chrome()

Solution 9 - Python

Before you add the chromedriver to your path, make sure it's the same version as your browser.

If not, you will need to match versions: either update/downgrade you chrome, and upgrade/downgrade your webdriver.

I recommend updating your chrome version as much as possible, and the matching the webdriver.

To update chrome:

  • On the top right corner, click on the three dots.
  • click help -> About Google Chrome
  • update the version and restart chrome

Then download the compatible version from here: http://chromedriver.chromium.org/downloads .

Note: The newest chromedriver doesn't always match the newest version of chrome!

Now you can add it to the PATH:

  1. create a new folder somewhere in your computer, where you will place your web drivers. I created a folder named webdrivers in C:\Program Files

  2. copy the folder path. In my case it was C:\Program Files\webdrivers

  3. right click on this PC -> properties:

enter image description here

  1. On the right click Advanced System settings
  2. Click Environment Variables
  3. In System variables, click on path and click edit
  4. click new
  5. paste the path you copied before
  6. click OK on all the windows

Thats it! I used pycharm and I had to reopen it. Maybe its the same with other IDEs or terminals.

Solution 10 - Python

Best way for sure is here:

Download and unzip chromedriver and put 'chromedriver.exe' in C:\Python27\Scripts and then you need not to provide the path of driver, just

driver= webdriver.Chrome()

You are done no need to add paths or anything

Solution 11 - Python

Some additional input/clarification for future readers of this thread, to avoid tinkering with the PATH env. variable at the Windows level and restart of the Windows system: (copy of my answer from https://stackoverflow.com/a/49851498/9083077 as applicable to Chrome):

(1) Download chromedriver (as described in this thread earlier) and place the (unzipped) chromedriver.exe at X:\Folder\of\your\choice

(2) Python code sample:

import os;
os.environ["PATH"] += os.pathsep + r'X:\Folder\of\your\choice';

from selenium import webdriver;
browser = webdriver.Chrome();
browser.get('http://localhost:8000')
assert 'Django' in browser.title

Notes: (1) It may take about 5 seconds for the sample code (in the referenced answer) to open up the Firefox browser for the specified url. (2) The python console would show the following error if there's no server already running at the specified url or serving a page with the title containing the string 'Django': assert 'Django' in browser.title AssertionError

Solution 12 - Python

When you unzip chromedriver, please do specify an exact location so that you can trace it later. Below, you are getting the right chromedriver for your OS, and then unzipping it to an exact location, which could be provided as argument later on in your code.

unzip chromedriver_linux64.zip -d /home/virtualenv/python2.7.9/

Solution 13 - Python

If you are working with robot framework RIDE. Then you can download Chromedriver.exe from its official website and keep this .exe file in C:\Python27\Scripts directory. Now mention this path as your environment variable eg. C:\Python27\Scripts\chromedriver.exe.

Restart your computer and run same test case again. You will not get this problem again.

Solution 14 - Python

EXECUTABLE PATH HAS BEEN DEPRECATED!

if you get the exectuable_path ash been deprecated warning, here is the fix...

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
def test_me(my_name):
    s=Service(ChromeDriverManager().install())    
    chrome_driver = webdriver.Chrome(service=s)
    ...

Solution 15 - Python

Could try to restart computer if it doesn't work after you are quite sure that PATH is set correctly.

In my case on windows 7, I always got the error on WebDriverException: Message: for chromedriver, gecodriver, IEDriverServer. I am pretty sure that i have correct path. Restart computer, all work

Solution 16 - Python

I encountered the same problem as yours. I'm using PyCharm to write programs, and I think the problem lies in environment setup in PyCharm rather than the OS. I solved the problem by going to script configuration and then editing the PATH in environment variables manually. Hope you find this helpful!

Solution 17 - Python

When I downloaded chromedriver.exe I just move it in PATH folder C:\Windows\System32\chromedriver.exe and had exact same problem.

For me solution was to just change folder in PATH, so I just moved it at Pycharm Community bin folder that was also in PATH. ex:

  • C:\Windows\System32\chromedriver.exe --> Gave me exception
  • C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.3\bin\chromedriver.exe --> worked fine

Solution 18 - Python

Had this issue with Mac Mojave running Robot test framework and Chrome 77. This solved the problem. Kudos @Navarasu for pointing me to the right track.

$ pip install webdriver-manager --user # install webdriver-manager lib for python
$ python # open python prompt

Next, in python prompt:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())

# ctrl+d to exit

This leads to the following error:

Checking for mac64 chromedriver:xx.x.xxxx.xx in cache
There is no cached driver. Downloading new one...
Trying to download new driver from http://chromedriver.storage.googleapis.com/xx.x.xxxx.xx/chromedriver_mac64.zip
...
TypeError: makedirs() got an unexpected keyword argument 'exist_ok'
  • I now got the newest download link
    • Download and unzip chromedriver to where you want
    • For example: ~/chromedriver/chromedriver

Open ~/.bash_profile with editor and add:

export PATH="$HOME/chromedriver:$PATH"

Open new terminal window, ta-da 

Solution 19 - Python

As Aphid mentioned in his comment, if you want to do it manually, you have to include only the directory where your webdriver is stored, not the executable:

Example:

RIGHT:

PATH=$PATH:/path/to/webdriver/folder

WRONG:

PATH=$PATH:/path/to/webdriver/chromedriver.exe


Windows System Variable and CMD Test:

enter image description here

Solution 20 - Python

In my case, this error disappears when I have copied chromedriver file to c:\Windows folder. Its because windows directory is in the path which python script check for chromedriver availability.

Solution 21 - Python

If you are using remote interpreter you have to also check if its executable PATH is defined. In my case switching from remote Docker interpreter to local interpreter solved the problem.

Solution 22 - Python

Check the path of your chrome driver, it might not get it from there. Simply Copy paste the driver location into the code.

Solution 23 - Python

Add the webdriver(chromedriver.exe or geckodriver.exe) here C:\Windows. This worked in my case

Solution 24 - Python

The best way is maybe to get the current directory and append the remaining address to it. Like this code(Word on windows. On linux you can use something line pwd): webdriveraddress = str(os.popen("cd").read().replace("\n", ''))+'\path\to\webdriver'

Solution 25 - Python

I had this problem on Webdriver 3.8.0 (Chrome 73.0.3683.103 and ChromeDriver 73.0.3683.68). The problem disappeared after I did

pip install -U selenium

to upgrade Webdriver to 3.14.1.

Solution 26 - Python

> The simple solution is that download the chrome driver and move the > executable file to the folder from which you run the python file.

Solution 27 - Python

For mac osx users

    brew tap homebrew/cask
    brew cask install chromedriver

Solution 28 - Python

For MAC users:

  1. Download Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/downloads

2.In Terminal type "sudo nano /etc/paths"

3.Add line with path to Cromedriver as example: "/Users/username/Downloads"

  1. Try to run your test again!

Solution 29 - Python

(for Mac users) I have the same problem but i solved by this simple way: You have to put your chromedriver.exe in the same folder to your executed script and than in pyhton write this instruction :

import os

os.environ["PATH"] += os.pathsep + r'X:/your/folder/script/'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionsteady_progressView Question on Stackoverflow
Solution 1 - PythonNavarasuView Answer on Stackoverflow
Solution 2 - PythonlmNtView Answer on Stackoverflow
Solution 3 - PythonBoris VView Answer on Stackoverflow
Solution 4 - PythonGiorgos MyrianthousView Answer on Stackoverflow
Solution 5 - PythonAndrea BiselloView Answer on Stackoverflow
Solution 6 - PythonJames0007View Answer on Stackoverflow
Solution 7 - PythonAnnaSummerShineView Answer on Stackoverflow
Solution 8 - PythonPraveen Kumar CView Answer on Stackoverflow
Solution 9 - PythonAlon GouldmanView Answer on Stackoverflow
Solution 10 - Pythonnirupam kapoorView Answer on Stackoverflow
Solution 11 - PythonSnidhi SofproView Answer on Stackoverflow
Solution 12 - PythonHarshdeep SinghView Answer on Stackoverflow
Solution 13 - PythonRahul TiwariView Answer on Stackoverflow
Solution 14 - Pythonenjoi4life411View Answer on Stackoverflow
Solution 15 - PythonlearningBunnyView Answer on Stackoverflow
Solution 16 - Pythonsia1998View Answer on Stackoverflow
Solution 17 - PythonDenis ImamovicView Answer on Stackoverflow
Solution 18 - PythonsampohView Answer on Stackoverflow
Solution 19 - PythonReneView Answer on Stackoverflow
Solution 20 - PythonHamidView Answer on Stackoverflow
Solution 21 - PythonRafałView Answer on Stackoverflow
Solution 22 - PythonChandyShotView Answer on Stackoverflow
Solution 23 - PythonSuguresh SoppimathView Answer on Stackoverflow
Solution 24 - Pythonuser10705083View Answer on Stackoverflow
Solution 25 - PythonSilas S. BrownView Answer on Stackoverflow
Solution 26 - PythonPraveen KumarView Answer on Stackoverflow
Solution 27 - PythonGirish BhasinView Answer on Stackoverflow
Solution 28 - PythonMikhail KryukovView Answer on Stackoverflow
Solution 29 - Pythonwalid_dataView Answer on Stackoverflow