0

Before you rate me, I must say that I read almost every answer on this site about who had my same problem, but i found no answer.

For example there the one who asked the question accepted the first answer, but copy-pasting the code in the answer the same error was raised.

An other example there where is linked this video, which doesn't explain much, but there no error is raised, instead of my code when I copied it from the video. (he doesn't write .exe, so probably an error would be found in his code too)

This one has exactly my same problem, so it would be perfect, but no answer was accepted.

Here's the last line of the error:

selenium.common.exceptions.WebDriverException: Message: 'chrome.exe %s' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

At the end of the exception message there's a link, which says they migrated to another site.

The error message here:

FileNotFoundError: [WinError 2] Impossibile trovare il file specificato

During handling of the above exception, another exception occurred:

#Something else beetwen

selenium.common.exceptions.WebDriverException: Message: 'chrome.exe %s' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Here's the beginning of my code:

from selenium import webdriver

chrome_path = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s"

driver = webdriver.Chrome(executable_path=chrome_path)

I'm sure the path is correct, 'cause I copy-pasted it from the chrome.exe properties.

I also tried it without %s, and it raises a different error:

selenium.common.exceptions.WebDriverException: Message: Service C:/Program Files (x86)/Google/Chrome/Application/chrome.exe unexpectedly exited. Status code was: 0

Can someone help explaining me what's wrong?

Thanks


EDIT

I searched with file explorer for "chromedriver", and nothing was found.

FLAK-ZOSO
  • 3,873
  • 4
  • 8
  • 28

2 Answers2

1

As I see your path is to Chrome (browser) exe file instead of chromedriver.exe used by Selenium

Prophet
  • 32,350
  • 22
  • 54
  • 79
  • C:/Program Files (x86)/Google/Chrome/Application/chrome.exe C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s /Program Files (x86)/Google/Chrome/Application/chrome.exe /Program Files (x86)/Google/Chrome/Application/chrome.exe %s All this possibilities don't work – FLAK-ZOSO Jun 09 '21 at 10:15
  • 1
    Do you have the chromedriver.exe file there? – Prophet Jun 09 '21 at 10:16
  • i only have the chrome.exe file there... there's no file called chromedriver on my pc, and it's strange because I used chrome as main browser for months... – FLAK-ZOSO Jun 09 '21 at 10:24
  • 1
    chrome.exe is BROWSER file. Selenium is not a bowser. You need chromedriver.exe to work with Selenium with chrome browser – Prophet Jun 09 '21 at 10:57
1

You can try as following

driver = webdriver.Chrome(executable_path=r'Path_to_chrome_Driver\\chromedriver.exe')

You are locating chrome browser exe location. Please download chrome driver for selenium Chromedriver. Then enter the chrome driver location.

Note: Make sure you have downloaded the correct chromedriver based on your chrome browser version.

Mat
  • 178
  • 7
  • chrome_path = r"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s" driver = webdriver.Chrome(executable_path = chrome_path) Isn't it the same thing? – FLAK-ZOSO Jun 09 '21 at 10:16
  • 1
    No. You are using Chrome Browser exe file. Please download chrome driver for selenium. Put in a location. Then enter the location in executable_path=r'Path_to_chrome_Driver\\chromedriver.exe' – Mat Jun 09 '21 at 10:29
  • Ok, I found it, there's no Win 64x version, I'll download 32x one – FLAK-ZOSO Jun 09 '21 at 10:31
  • 1
    You can download from here. https://chromedriver.chromium.org/downloads – Mat Jun 09 '21 at 10:33
  • THANKS A LOT it worked, I didn't know that chromedriver must be installed. – FLAK-ZOSO Jun 09 '21 at 10:35