Home > Net >  Chromedriver added to Path but still getting Message: 'chromedriver_win32' executable need
Chromedriver added to Path but still getting Message: 'chromedriver_win32' executable need

Time:07-08

OS: Windows 11 using WSL2

Issue: I am trying to use selenium for python and have trouble with the location of the chromedriver executable.

  1. I downloaded the chromedriver executable from https://chromedriver.chromium.org/downloads in correspondence with the version of chrome I have (v. 103).

  2. I unzipped the folder and stored it in the downloads folder of my desktop.

  3. I added the folder path where the .exe is located to my PATH in environment variables.

\wsl.localhost\Ubuntu\home\my_username\chromedriver_win32\

  1. I run the following code:

     # Import
     from selenium import webdriver
    
     # Create a driver to help scrape the website
     driver = webdriver.Chrome()
    
     # Website wanting to scrape
     website = "https://www.adamchoi.co.uk/overs/detailed"
    
     # Opens the browser
     driver.get(website)
    
  2. When I run my py file with this code in the terminal I get this error message:

     python scraper.py
    

Message: 'chromedriver' executable needs to be in PATH.

OTHER SOLUTIONS ATTEMPTED

  1. Method 2 from https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/

In this case, the folder was not added to the PATH and the same message occurs.

  1. The first and second answer in Error message: "'chromedriver' executable needs to be available in the path"

When I try the first answer I get the same message.

When I try the second answer I get:

KeyError: 'google-chrome'

  1. I tried the top voted answer in DeprecationWarning: executable_path has been deprecated selenium python

and get the same:

KeyError: 'google-chrome'

  1. I tried the answer from Mori on Nov 8, 2021 in DeprecationWarning: executable_path has been deprecated selenium python and get

Message: 'chromedriver' executable needs to be in PATH.

I've been working at this for around 3 hours with no progress. Thanks in advance.

CodePudding user response:

Try this:

 # Import
 from selenium import webdriver

 # Create a driver to help scrape the website

 # Add path
 PATH = "Path/To/Your/Driver"
 driver = webdriver.Chrome(PATH)

 # Website wanting to scrape
 website = "https://www.adamchoi.co.uk/overs/detailed"

 # Opens the browser
 driver.get(website)

Make sure you put the path to the executable file not the folder including it.

CodePudding user response:

As you have ...."unzipped the folder and stored it in the downloads folder of my desktop"..

Ideally your line of code should be:

driver = webdriver.Chrome(r'C:\Users\username\Desktop\chromedriver.exe')
  • Related