Python Chromedriver:“;FileNotFoundError:[WinError 2]系统找不到指定的文件";错误

Python Chromedriver:“;FileNotFoundError:[WinError 2]系统找不到指定的文件";错误,python,selenium-chromedriver,Python,Selenium Chromedriver,我一直在寻找答案,但什么也找不到。它似乎坚持说它找不到指定的文件,然后检查路径,但即使这样也看不到:/I已将目录放在路径中: 节目: from selenium import webdriver driver = webdriver.Chrome() driver.get("https://www.google.com/") 错误: Traceback (most recent call last): File "C:\Users\dilri\AppData\Local\Programs\

我一直在寻找答案,但什么也找不到。它似乎坚持说它找不到指定的文件,然后检查路径,但即使这样也看不到:/I已将目录放在路径中:

节目:

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

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 start
    stdout=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_child
    startupinfo)
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 "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 start
    os.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
回溯(最近一次呼叫最后一次):
文件“C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py”,第74行,开始
stdout=self.log\u文件,stderr=self.log\u文件)
文件“C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py”,第707行,在uu init中__
恢复信号,启动新会话)
文件“C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py”,第990行,在执行子进程中
startupinfo)
FileNotFoundError:[WinError 2]系统找不到指定的文件
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“H:\temp.py”,第2行,在
driver=webdriver.Chrome()
文件“C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py”,第62行,在\uu init中__
self.service.start()
文件“C:\Users\dilri\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py”,第81行,开始
os.path.basename(self.path)、self.start\u错误消息)
selenium.common.exceptions.WebDriverException:消息:“chromedriver”可执行文件需要位于路径中。请看https://sites.google.com/a/chromium.org/chromedriver/home

如果有人能帮上忙,我们将不胜感激。

您可以试着直接通过路径

因此,我的dekstop上有webdriver文件,因此:

webdriver.Chrome('C:/Users/adam/Desktop/chromedriver.exe')

您可以获取webdriver

我遇到了相同的问题,并使用选项方法解决了它

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/")

希望它能解决您的问题。

您可以使用以下方法:

from selenium import webdriver

browser = webdriver.Chrome(r"*your path here*")
如何获得路径? 如果在windows系统上,则转到webdriver的提取位置,按shift键并选择“复制为路径”