Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selenium - chromedriver executable needs to be in PATH [duplicate]

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:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\subprocess.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:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.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:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
    self.stop()
  File "C:\Users\sebastian\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
like image 749
Sebastian Nielsen Avatar asked Nov 11 '16 20:11

Sebastian Nielsen


People also ask

How do I fix Chromedriver executable in path?

To solve the Selenium error "WebDriverException: Message: 'chromedriver' executable needs to be in PATH", install and import the webdriver-manager module by running pip install webdriver-manager . The module simplifies management of binary drivers for different browsers.

Does Selenium need to be in path?

selenium - chromedriver executable needs to be in PATH.

What is the default location of Chromedriver?

Chromium/Google Chrome Note : For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. You can also override the Chrome binary location following Using a Chrome executable in a non-standard location .


3 Answers

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')
    
like image 160
Maximilian Peters Avatar answered Oct 12 '22 11:10

Maximilian Peters


Try this :

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

driver = webdriver.Chrome(ChromeDriverManager().install())
like image 55
BUGATTI AJAY Avatar answered Oct 12 '22 10:10

BUGATTI AJAY


Another way is download and unzip chromedriver and put 'chromedriver.exe' in C:\Python27\Scripts and then you need not to provide the path of driver, just

driver= webdriver.Chrome()

will work

like image 31
thebadguy Avatar answered Oct 12 '22 10:10

thebadguy