Error message: “‘chromedriver’ executable needs to be available in the path” In Python

Error message: “‘chromedriver’ executable needs to be available in the path” is a popular error which happens when we are not able to find the chromedriver executable binary.

In this post I am going to try and replicate this error and solve it and try to understand the root of the error, I am also going to present other possible solutions which worked for other developers.

Describing Error message: “‘chromedriver’ executable needs to be available in the path”

Selenium is a great way to run Python automation scripts, to replicate the error we will start by downloading the chromedriver on windows.

The second step is to Unzip the downloaded zip file.

The third step is to add the path to chromedriver_win32 to the env variable “path”.

Then we can run our code

                                                                       #
from selenium import webdriver

driver = webdriver.Chrome()
                                                                       #

Pay attention to the warning message bellow.

                                                                       #
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
                                                                       #

Fortunately, there are a lot of possible solutions to this problem, let us solve this error together.

Solution 1 : quickly install webdriver-manager (webdriver manager)

The first solution is simple and straightforward. You do not have to do everything without shortcuts.

We can use the webdriver-manager. To install it just run the command bellow.

                                                                       #
pip install webdriver-manager
                                                                       #

Now pay attention to how you can use the webdriver manager in your code.

                                                                       #
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

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

Solution 2 : use sudo to install chromedriver

Another solution is to use sudo to install the chromedriver. Like in the command bellow.

                                                                       #
sudo apt install chromium-chromedriver
                                                                       #

This works fine for Ubuntu. But for other OSs and Linux versions the syntax could be different.

Solution 3 : restart your IDE In order to reload path variables

This is a great solution for windows users.

In order to reload path variables you should restart your IDE.

After restarting try running your code. In our example the code was

                                                                       #
from selenium import webdriver

driver = webdriver.Chrome()
                                                                       #

I hope this worked for you, If it did, consider donating if you want to help our effort at the error’s den, our Kofi account is at the top of this page, this is not an obligation, this website is free to browse.

Summing-up

I hope this article helped you solve the chromedriver error, If not, I hope the solutions presented here guided you at least in the right direction. Keep coding guys and cheers, see you in another post.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/