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

2024/10/15 23:19:13

Have looked for an answer, but couldn't find anything. It seems insistent on saying it can't find the file specified and then checks PATH, but can't see it even then :/ I've put the directory in PATH: http://imgur.com/a/ZP59w

Program:

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com/")

Error:

Traceback (most recent call last):File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\site-       packages\selenium\webdriver\common\service.py", line 74, in startstdout=self.log_file, stderr=self.log_file)File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-  32\lib\subprocess.py", line 707, in __init__restore_signals, start_new_session)File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-     32\lib\subprocess.py", line 990, in _execute_childstartupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specifiedDuring handling of the above exception, another exception occurred:Traceback (most recent call last):File "H:\temp.py", line 2, in <module>driver = webdriver.Chrome()File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\site-   packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__self.service.start()File "C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\site-  packages\selenium\webdriver\common\service.py", line 81, in startos.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

If anyone could help that would be greatly appreciated.

Answer

I had the same problem and solved it by using Options method.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\Program Files (x86)\Google\Chrome Dev\Application\chrome.exe"
driver = webdriver.Chrome(chrome_options=options, executable_path=r"C:\Program Files (x86)\Google\chromedriver.exe", )
driver.get("https://www.google.com/")

Hope it solved your problem.

https://en.xdnf.cn/q/117775.html

Related Q&A

Python - mutable default arguments to functions

I was going through https://docs.python.org/3.5/tutorial/controlflow.html#default-argument-values. I modified the example there a little bit as below:x = [4,5] def f(a, L=x):L.append(a)return Lx = [8,9…

Python: remove duplicate items from a list while iterating

I have a list named results, I want to get rid of the duplicate items in the list, the expected result and my results does not match, I checked my code but cannot find what is the problem, what happene…

Python - SciPy Kernal Estimation Example - Density 1

Im currently working through this SciPy example on Kernal Estimation. In particular, the one labelled "Univariate estimation". As opposed to creating random data, I am using asset returns. …

PyQt QFileDialog custom proxy filter not working

This working code brings up a QFileDialog prompting the user to select a .csv file:def load(self,fileName=None):if not fileName:fileName=fileDialog.getOpenFileName(caption="Load Existing Radio Log…

If I have Pandas installed correctly, why wont my import statement recognize it?

Im working on a project to play around with a csv file, however, I cant get pandas to work. Everything I have researched so far has just told me to make sure that pandas is installed. Using pip I have …

Python Issues with a Class

I am having issues with my below class. I keep getting the below traceback, butI am not sure were I am going wrong. I am expecting to see a dictionary with photo tags. Any help would be great. Tracebac…

Dynamically populate drop down menu with selection from previous drop down menu

I have a cgi script written in Python. There are two drop down menus and then a submit button. Id like to be able to make a selection from the first menu, and based off that choice, have the second dro…

Web Scrape page with multiple sections

Pretty new to python... and Im trying to my hands at my first project.Been able to replicate few simple demo... but i think there are few extra complexities with what Im trying to do.Im trying to scrap…

Python recv Loop

I am try to display data that is sent over a socket via an iteration from a loop. The way I have it at the moment isnt working on the Admin client. What should I do to fix my loop? Thank youAdmin t…

gtk+ python entry color [closed]

Its difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying thi…