1

When I use "webdriver.Chrome()". I encountering an error when running this code:

from selenium import webdriver
driver = webdriver.Chrome()

Here's the error that showes up:

Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    driver = webdriver.Chrome()
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

I don't have any idea what to make of this. And I haven't found anyone with the same issue. Anyone know a fix?

  • 1
    `PATH` is an environment variable which, among other things, is used to tell python which directories (folders) executables (such as `chromedriver.exe`) live in. The error you're getting is complaining that python can't find `chromedriver.exe` in your `PATH` environment variable, so you either need to find a way to add the directory where `chromedriver.exe` is stored on your computer into the `PATH` environment variable, or specify the full path to the executable when you call `webdriver.Chrome()`. – rst-2cv Oct 09 '19 at 13:01

1 Answers1

0

You need to chromedriver binary and the path of binary as below:

driver = webdriver.Chrome('/usr/local/bin/chromedriver.exe')

Download your chromedriver as per your chrome version from below location :

https://chromedriver.storage.googleapis.com/index.html

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125