0

Tried executing

from selenium import webdriver

browser=webdriver.Chrome()

browser.get('http://www.google.com')

but doesn't execute and throws error

=RESTART: C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\drive.py =
Traceback (most recent call last):
  File "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Phani\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 "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\drive.py", line 4, in <module>
    browser=webdriver.Chrome()
  File "C:\Users\Phani\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\Phani\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

properly installed selenium using pip install

Please Help!!

tnotstar
  • 1,343
  • 1
  • 16
  • 26
Hema
  • 1
  • 2
  • 1
    Possible duplicate of [Selenium using Python - Geckodriver executable needs to be in PATH](https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path) – sytech Mar 20 '19 at 20:39

3 Answers3

1

This isn't working because you haven't provide path of the chrome driver.WebDriver doesn't know where is the chromedriver path.

driver = webdriver.Chrome("path of the chrome driver Chromedriver.exe")

for example:

from selenium import webdriver
driver = webdriver.Chrome("d:/chromedriver/Chromedriver.exe")
driver.get("https://www.google.com")
KunduK
  • 32,888
  • 5
  • 17
  • 41
1

You can try Firefox for this purpose:

First Download Geckodriver from here: https://github.com/mozilla/geckodriver/releases/tag/v0.24.0

from selenium import webdriver
fox = webdriver.Firefox(executable_path='/path/to/downloaded/gecko/driver')
fox.get("https://www.google.com")

Same could be done with google chrome :

You can download chrome driver from here:

https://sites.google.com/a/chromium.org/chromedriver/home

No need to setup PATH variable.

Neeraj Sonaniya
  • 375
  • 4
  • 13
0

I have just fixed the issue. You need to download an updated version of Google Chrome. For instance, my old version was 96 but now it is 101. That is it.