selenium – chromedriver executable needs to be in PATH

Error message:

‘chromedriver’ executable needs to be in PATH

I was trying to code a script using selenium in pycharm, however the error above occured. 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.

error shown below:

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 <module>
    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: <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x01EDEAF0>>
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'

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can download ChromeDriver here:
https://sites.google.com/chromium.org/driver/

Then you have multiple options:

  • add it to your system path
  • put it in the same directory as your python script
  • specify the location directly via executable_path
     driver = webdriver.Chrome(executable_path='C:/path/to/chromedriver.exe')

Method 2

Try this :

pip install webdriver-manager
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

Method 3

Another way is download and unzip chromedriver and put ‘chromedriver.exe’ in C:Python27Scripts and then you need not to provide the path of driver, just

driver= webdriver.Chrome()

will work

Method 4

An answer from 2020. The following code solves this. A lot of people new to selenium seem to have to get past this step.
Install the chromedriver and put it inside a folder on your desktop. Also make sure to put the selenium python project in the same folder as where the chrome driver is located.

Change USER_NAME and FOLDER in accordance to your computer.

For Windows

driver = webdriver.Chrome(r"C:UsersUSER_NAMEDesktopFOLDERchromedriver")

For Linux/Mac

driver = webdriver.Chrome("/home/USER_NAME/FOLDER/chromedriver")

Method 5

Do not include the ‘.exe’ in your file path.

For example:

from selenium import webdriver

driver = webdriver.Chrome(executable_path='path/to/folder/chromedriver')

Method 6

try this :

driver = webdriver.Chrome(ChromeDriverManager().install())

Method 7

Another way is download and unzip chromedriver and put ‘chromedriver.exe’ in C:Python27Scripts and then you need not to provide the path of driver, just

driver= webdriver.Chrome()

will work

Can testify that this also works for Python3.7.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x