1

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.

p.habermanm
  • 85
  • 1
  • 9

2 Answers2

0

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.

  • I just tried and I still get the same message "'chromedriver.exe' executable needs to be in PATH". In PATH, are you saying I include the filename/extension like chromedriver.exe? I also tried with an absolute path and a relative path like "../path/to/folder/chromedriver.exe". Still no luck. Keeps saying I need to add it to PATH. – p.habermanm Jul 07 '22 at 06:26
  • Try using this line ```driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))``` This is the only other fix I can think of, keep in mind this only works in Selenium v4 – Yahya Murad Jul 07 '22 at 18:00
  • I tried this one as well in accordance with the answer from enjoi4life411 in this post -> https://stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path. I made the additional imports (Service, ChromeDriverManager) and added the code you suggested in your comment. The result is " KeyError: 'google-chrome' " – p.habermanm Jul 08 '22 at 03:01
0

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')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Same message " 'C:\Users\my_username\Downloads\chromedriver.exe' executable needs to be in PATH ". I also tried it with and without the r at the beginning. Without the r I get "SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape". Finally I tried substituting the \ for /. Same result..."executable needs to be in path". One thing I forgot to mention, my username is a Chinese character. Wouldn't this be interpreted as a string though, I don't think it should matter. – p.habermanm Jul 08 '22 at 02:55
  • You just need to replace `username` with your actual (Chinese character based) username. Keep the other things intact. – undetected Selenium Jul 08 '22 at 11:12
  • Let's discuss the issue in [Selenium](https://chat.stackoverflow.com/rooms/223360/selenium) room. – undetected Selenium Jul 08 '22 at 11:14