0

I have difficulties in finding a solution, can you help me? This is the code text:

from selenium import webdriver
web = webdriver.Chrome("C:\ Users\giova\Desktop\chromedriver.exe")
web.get("https://www.youtube.com/")

This is the error that i receive when i run the program:

C:\Users\giova\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/giova/PycharmProjects/pythonProject/main.py
C:\Users\giova\PycharmProjects\pythonProject\main.py:2: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  web= webdriver.Chrome("C:\ Users\giova\Desktop\chromedriver.exe")
Traceback (most recent call last):
  File "C:\Users\giova\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1438, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Impossibile trovare il file specificato

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\giova\PycharmProjects\pythonProject\main.py", line 2, in <module>
    web= webdriver.Chrome("C:\ Users\giova\Desktop\chromedriver.exe")
  File "C:\Users\giova\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "C:\Users\giova\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 89, in __init__
    self.service.start()
  File "C:\Users\giova\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
1
  • is there a space before users ?
    – PDHide
    Commented Jun 22, 2022 at 9:16

1 Answer 1

2

The error you are getting is

FileNotFoundError: [WinError 2] Impossibile trovare il file specificato

My guess is, this is because of this line,

web = webdriver.Chrome("C:\ Users\giova\Desktop\chromedriver.exe")

You might want to check the path "C:\ Users\giova\Desktop\chromedriver.exe" and correct it.

It might be possible that the space before Users breaks the path and hence the file isn't found.

It would be best to go to the location of the chromedriver.exe file in your file browser and then copy the path from there to get the correct path.

4
  • i used the correct path and i copied it but it doesn't recognise it, I don't know what to do T.T
    – Mr.Layton
    Commented Jun 22, 2022 at 7:40
  • Are you getting the same error? or does it give a different error now? Commented Jun 22, 2022 at 7:46
  • yes, I'm getting the same error
    – Mr.Layton
    Commented Jun 22, 2022 at 17:59
  • ok, I resolved the problem. I was using the 4th version of selenium so I had to use another code: from selenium import webdriver from selenium.webdriver.chrome.service import Service driver = webdriver.Chrome(service=Service(r"C:\Users\giova\Desktop\chromedriver.exe")) driver.get("google.com")
    – Mr.Layton
    Commented Jun 22, 2022 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.