Python Forum
WebDriverException: 'chromedriver' executable needs to be in PATH
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WebDriverException: 'chromedriver' executable needs to be in PATH
#1
Running code to scrape items from the website and display it
from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd

driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")

products= []
prices = []
ratings = []

driver.get("https://www.flipkart.com/laptops/~buyback-guarantee-on-laptops-/pr?sid=6bo%2Cb5g&uniq")

content = driver.page_source
soup = BeautifulSoup(content)
for a in soup.findAll('a',href=True, attrs={'class':'_31qSD5'}):
    name=a.find('div', attrs={'class':'_3wU53n'})
    price=a.find('div', attrs={'class':'_1vC4OE _2rQ-NK'})
    rating=a.find('div', attrs={'class':'hGSR34 _2beYZw'})
    products.append(name.text)
    prices.append(price.text)
    ratings.append(rating.text) 
However an error comes :
Error:
runfile('/Users/aarav/Documents/MyProject/Python/Web_scraping.py', wdir='/Users/aarav/Documents/MyProject/Python') Traceback (most recent call last): File "/Users/aarav/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start stdin=PIPE) File "/Users/aarav/opt/anaconda3/lib/python3.7/subprocess.py", line 800, in __init__ restore_signals, start_new_session) File "/Users/aarav/opt/anaconda3/lib/python3.7/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/chromium-browser/chromedriver': '/usr/lib/chromium-browser/chromedriver' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/aarav/Documents/MyProject/Python/Web_scraping.py", line 7, in <module> driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver") File "/Users/aarav/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__ self.service.start() File "/Users/aarav/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 83, in start os.path.basename(self.path), self.start_error_message) WebDriverException: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
What happened?
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#2
The error is saying that the path in
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")
should be a full path to an .exe

Please see https://sites.google.com/a/chromium.org/...river/home
https://stackoverflow.com/questions/4055...be-in-path
Reply
#3
Well, I found the code in this site and started running it, and it shows this error.
I don't know, but I didn't modify anything while writing the code. How does it work for him and not me?
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#4
Have you downloaded the ChromeDriver executable?
Reply
#5
Nope, I don't think so. How to download/ check?
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#6
The link is in my first post and in the error message you received.
Reply
#7
Here a example of a working setup.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
import time

#--| Setup
options = Options()
#options.add_argument("--headless")
#options.add_argument("--window-size=1980,1020")
#options.add_argument('--disable-gpu')
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
browser.get("https://www.flipkart.com/laptops/~buyback-guarantee-on-laptops-/pr?sid=6bo%2Cb5g&uniq")
time.sleep(2)
soup = BeautifulSoup(browser.page_source, 'lxml')
# Example of using both to parse
use_bs4 = soup.find('div', class_="col col-7-12")
print(use_bs4.text)
print('*' * 25)
use_sel = browser.find_elements_by_css_selector('div > div._1vC4OE._2rQ-NK')
print(use_sel[0].text)
Output:
Apple MacBook Air Core i5 5th Gen - (8 GB/128 GB SSD/Mac OS Sierra) MQD32HN/A A14664.724,087 Ratings & 2,715 ReviewsIntel Core i5 Processor (5th Gen)8 GB DDR3 RAM64 bit Mac OS Operating System128 GB SSD33.78 cm (13.3 inch) Display1 Year Carry In Warranty ************************* ₹65,990
So this Path is for Windows,do you use Mac?
It's the same way,but use chromedriver_mac64.zip then there is no .exe only chromedriver.

If uncomment like this browser will not start up.
#--| Setup
options = Options()
options.add_argument("--headless")
options.add_argument("--window-size=1980,1020")
options.add_argument('--disable-gpu')
Reply
#8
I have used selenium too. Make sure to include the extension .exe, like Chromedriver.exe. Simply writing Chromedriver implies it's a folder.
Reply
#9
.exe is for windows, right? What about mac?
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#10
(Jun-09-2020, 05:37 PM)pyzyx3qwerty Wrote: .exe is for windows, right? What about mac?

(Jun-09-2020, 03:46 PM)snippsat Wrote: So this Path is for Windows,do you use Mac?
It's the same way,but use chromedriver_mac64.zip then there is no .exe only chromedriver.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium undetected Chromedriver Bot Laurin0000 1 3,967 Apr-13-2023, 09:20 PM
Last Post: Clixmaster
  enable flash using selenium chromedriver Fre3k 1 4,248 Nov-27-2020, 12:15 PM
Last Post: JellyCreeper6
  Selenium Chromedriver Automation Help lessthanthree 1 2,115 May-05-2020, 11:03 PM
Last Post: Larz60+
  How to identify chromedriver version? metulburr 2 7,461 Jun-13-2019, 11:37 PM
Last Post: metulburr
  Chromedriver launch new tab gahhon 15 9,727 Feb-17-2019, 06:22 PM
Last Post: metulburr
  chromedriver.exe issue gahhon 2 2,766 Feb-12-2019, 12:09 PM
Last Post: metulburr
  Selenium chromedriver and click action Gilles95 4 13,198 Feb-07-2018, 07:28 PM
Last Post: Gilles95
  Getting error 'geckodriver' executable needs to be in PATH. sumandas89 2 37,554 Jan-11-2018, 07:54 AM
Last Post: sumandas89

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020