0

I'm trying to run multiple Python scripts using shell-scripting. As a trial I just wanted to see if one script would run. I am using Spyder-terminal to run my script. I run my script with the following code:

python C:\USERS\DAVID\DESKTOP\SELENIUM\SCRIPT1.PY

But I receive the following message:

C:\Users\David>python C:\USERS\DAVID\DESKTOP\SELENIUM\SCRIPT1.PY
Traceback (most recent call last):
  File "C:\Users\David\anaconda3\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\David\anaconda3\lib\subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\David\anaconda3\lib\subprocess.py", line 1311, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
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\DAVID\DESKTOP\SELENIUM\SCRIPT1.PY", line 10, in <module>
    driver=webdriver.Chrome(options=options)
  File "C:\Users\David\anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "C:\Users\David\anaconda3\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 90, in __init__
    self.service.start()
  File "C:\Users\David\anaconda3\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

The chromedriver is located in the following path:

C:\Users\David\Desktop\Selenium\chromedriver.exe
Charles Duffy
  • 257,635
  • 38
  • 339
  • 400
  • `cd` into that directory and run the script there, or add the location chromedriver is in to your PATH. – Charles Duffy Apr 25 '22 at 12:05
  • It's not normal or expected for things in the same directory as your program to be in the PATH by default, which is the unfounded assumption your code is making leading to this error. On Windows (and only Windows among modern operating systems, everyone else fixed this for security reasons) the _current working directory_ is in your PATH by default; that's why it works when you start your program from an IDE that sets the working directory to where the script is located. – Charles Duffy Apr 25 '22 at 12:07
  • Following the steps in https://stackoverflow.com/questions/1432924/python-change-the-scripts-working-directory-to-the-scripts-own-directory will solve this. – Charles Duffy Apr 25 '22 at 12:10

0 Answers0