Selenium - chromedriver executable needs to be in PATH

454    Asked by AishwaryaJhadav in Java , Asked on Jun 1, 2021
'chromedriver' executable needs to be in PATH

I was trying to code a script using selenium in pycharm, however, the above error occurred. I have already linked my selenium to pycharm as seen here (fresh and up to date).

I am new to selenium, isn't chromedriver in the folder "selenium." If it isn't, where can I find it and add it to the path?

By the way, I tried typing "chromedriver" in cmd, however, it wasn't recognized as an internal or external command.

The error shown below was displayed:

Traceback (most recent call last):
  File "C:UserssebastianAppDataLocalProgramsPythonPython35-32libsite-packagesseleniumwebdrivercommonservice.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:UserssebastianAppDataLocalProgramsPythonPython35-32libsubprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:UserssebastianAppDataLocalProgramsPythonPython35-32libsubprocess.py", line 1224, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Permission denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:/Users/sebastian/PycharmProjects/web/bot.py", line 10, in
    browser = webdriver.Chrome("C:/Users/sebastian/desktop/selenium-3.0.1")
  File "C:UserssebastianAppDataLocalProgramsPythonPython35-32libsite-packagesseleniumwebdriverchromewebdriver.py", line 62, in __init__
    self.service.start()
  File "C:UserssebastianAppDataLocalProgramsPythonPython35-32libsite-packagesseleniumwebdrivercommonservice.py", line 76, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'selenium-3.0.1' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Exception ignored in: >
Traceback (most recent call last):
  File "C:UserssebastianAppDataLocalProgramsPythonPython35-32libsite-packagesseleniumwebdrivercommonservice.py", line 163, in __del__
    self.stop()
  File "C:UserssebastianAppDataLocalProgramsPythonPython35-32libsite-packagesseleniumwebdrivercommonservice.py", line 135, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'

Answered by Abhinav Pillai

Incase, you are facing chromedriver' executable needs to be in path error in your code then follow the steps shown below:

Add it to your system path

Put it in the same directory where you have your python script

Specify the location directly via executable_path like this:

driver = webdriver.Chrome(executable_path='C:/path/to/chromedriver.exe')

Your Answer

Interviews

Parent Categories