1

Installed Selenium and the latest stable Chromedriver built.

As suggested I put it into the environment variable path:

enter image description here

My code looks like this :

options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('start-maximized')
options.add_argument('disable-infobars')
options.add_argument("--disable-extensions")

prefs = {"profile.managed_default_content_settings.images": 2}
options.add_experimental_option("prefs", prefs)

driver = webdriver.Chrome('./driver/chromedriver', options=options)

timeout = 3

The error that I am getting is :

WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

I even tried the following in the command line :

chromedriver --whitelisted-ips=""

Can someone please provide some help how I can resolve this.

The whole output error is this :

FileNotFoundError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self) 75 stderr=self.log_file, ---> 76 stdin=PIPE) 77 except TypeError:

~\Anaconda3\lib\subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text) 774 errread, errwrite, --> 775 restore_signals, start_new_session) 776 except:

~\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session) 1177 os.fspath(cwd) if cwd is not None else None, -> 1178 startupinfo) 1179 finally:

FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

WebDriverException                        Traceback (most recent call last)
<ipython-input-9-3b7827e2d128> in <module>
      2 from selenium import webdriver
      3 
----> 4 driver = webdriver.Chrome('/path/to/chromedriver')  # Optional argument, if not specified will search path.
      5 driver.get('http://www.google.com/');
      6 time.sleep(5) # Let the user actually see something!

~\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
     71             service_args=service_args,
     72             log_path=service_log_path)
---> 73         self.service.start()
     74 
     75         try:

~\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self)
     81                 raise WebDriverException(
     82                     "'%s' executable needs to be in PATH. %s" % (
---> 83                         os.path.basename(self.path), self.start_error_message)
     84                 )
     85             elif err.errno == errno.EACCES:
hmmmbob
  • 1,167
  • 5
  • 19
  • 33
  • Just put chromedriver in c:\windows - there's no point adding junk to your path. – pguardiario Mar 09 '20 at 00:54
  • 1
    I hope this is a joke. Adding junk to your windows directory is far worse than adding junk to your path. (it would be an option to change PATH locally though before calling the script.) – CherryDT Mar 09 '20 at 08:50

1 Answers1

0

The path entry needs to be C:\Users\skpok\Downloads\chromedriver_win32 and not C:\Users\skpok\Downloads\chromedriver_win32\chromedriver.exe.

The PATH environment variable lists folders in which to search for programs. It doesn't list the programs themselves.

(With your current configuration, the full path of the file would have to be C:\Users\skpok\Downloads\chromedriver_win32\chromedriver.exe\chromedriver.exe to be found.)


Also, it seems you are actually specifying the chrome driver path here:

driver = webdriver.Chrome('./driver/chromedriver', options=options)

The path ./driver/chromedriver conflicts with the path you showed before... Try removing this argument so that it actually looks in the PATH, or specify the correct file path here!

CherryDT
  • 25,571
  • 5
  • 49
  • 74
  • I tried both suggestions, and nothing changes :( Where could I have gone wrong or how can I find the mistake ? – hmmmbob Mar 09 '20 at 00:43
  • If you only recently added this entry, log off and on again or restart your computer. – CherryDT Mar 09 '20 at 00:45
  • Tried that as well .. just does not want to work :( – hmmmbob Mar 09 '20 at 00:56
  • I noticed another issue now and I updated my answer. You are specifying a file path actually: `./driver/chromedriver`! – CherryDT Mar 09 '20 at 01:00
  • Good Catch, unfortunately it still doesnt work. This is so frustrating :( – hmmmbob Mar 09 '20 at 04:50
  • Use [Process Monitor](https://learn.microsoft.com/en-us/sysinternals/downloads/procmon) and set a filter "path" "contains" "chromedriver", to see what paths it _tries_ to use (and fails) so it can become clearer how expectation and reality differ. – CherryDT Mar 09 '20 at 08:41