skip to Main Content

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.localhostUbuntuhomemy_usernamechromedriver_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.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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:UsersusernameDesktopchromedriver.exe')
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search