OS: Windows 11 using WSL2
Issue: I am trying to use selenium for python and have trouble with the location of the chromedriver executable.
I downloaded the chromedriver executable from https://chromedriver.chromium.org/downloads in correspondence with the version of chrome I have (v. 103).
I unzipped the folder and stored it in the downloads folder of my desktop.
I added the folder path where the .exe is located to my PATH in environment variables.
\wsl.localhost\Ubuntu\home\my_username\chromedriver_win32\
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)
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
In this case, the folder was not added to the PATH and the same message occurs.
- 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'
- I tried the top voted answer in DeprecationWarning: executable_path has been deprecated selenium python
and get the same:
KeyError: 'google-chrome'
- 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')