【问题标题】:Chromedriver: “FileNotFoundError: [Errno 2] No such file or directory:” ErrorChromedriver:“FileNotFoundError:[Errno 2] 没有这样的文件或目录:”错误
【发布时间】:2020-12-08 11:53:59
【问题描述】:

我无法解决这个问题。 我尝试了通过以下地址找到的所有解决方案,但问题没有解决。 请帮帮我。

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

程序:

from selenium import webdriver

driver = webdriver.Chrome("C:\chromedriver\chromedriver.exe")
url = 'https://www.naver.com'
driver.get(url)

错误:

Traceback (most recent call last):
  File "/home/jsbang/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\chromedriver\\chromedriver.exe': 'C:\\chromedriver\\chromedriver.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "modu_pers_auto.py", line 21, in <module>
    driver = webdriver.Chrome(chrome_options=options, executable_path=r"C:\chromedriver\chromedriver.exe", )
  File "/home/jsbang/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/home/jsbang/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'C:\chromedriver\chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

【问题讨论】:

    标签: python selenium-chromedriver


    【解决方案1】:

    如果您的可执行文件确实存在,您应该提供有效路径:

    ("C:\\chromedriver\\chromedriver.exe")
    

    或

    ("C:/chromedriver/chromedriver.exe")
    

    【讨论】:

    • 我已经尝试过了。但问题并不顺利。
    猜你喜欢
    • 2019-12-12
    • 2018-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-28
    • 2019-04-01
    相关资源
    最近更新 更多