【问题标题】:Executable path needs to be in PATH in Python [duplicate]可执行路径需要在 Python 中的 PATH [重复]
【发布时间】:2020-11-25 07:28:11
【问题描述】:

我不断收到此错误:

Traceback (most recent call last):
  File "C:/Users/LENOVO/Desktop/Coding -Winson/PyCharm/opening_webs.py", line 3, in <module>
    driver = webdriver.Chrome('/path/to/chromedriver')
  File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\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://sites.google.com/a/chromium.org/chromedriver/home

每次我使用这段代码时:

from selenium import webdriver

webdriver.Chrome(executable_path= "Users\LENOVO\AppData\Local\Programs\Python\Python38-32\chromedriver.exe")

【问题讨论】:

  • 你需要在 python 中使用双 \ 作为路径。 IE。 webdriver.Chrome(executable_path= "Users\\LENOVO\\AppData\\Local\\Programs\\Python\\Python38-32\\chromedriver.exe")
  • 这与 MATLAB 有什么关系?请使用描述问题的标签,不要包含不相关的标签。
  • 错误消息显示“请参阅sites.google.com/a/chromium.org/chromedriver/home”。你这样做了吗?

标签: python python-3.x selenium-webdriver executable


【解决方案1】:

试试这个

webdriver.Chrome(executable_path= r"C:\\Users\\LENOVO\\AppData\\Local\\Programs\\Python\\Python38-32\\chromedriver.exe")

并确保那里有 chrome 驱动程序

不然还是会出现这个错误

Traceback (most recent call last): File "C:/Users/LENOVO/Desktop/Coding -Winson/PyCharm/opening_webs.py", line 3, in driver = webdriver.Chrome('/path/to/chromedriver') File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in init self.service.start() File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\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://sites.google.com/a/chromium.org/chromedriver/home

如果问题仍然存在,请尝试将 chrome 可执行文件的副本放在 python 程序所在的当前路径中

【讨论】:

  • 新错误,这个版本的ChromeDriver只支持Chrome 85版,需要beta版的chrome吗?
  • 不要下载最新版的chrome驱动和chrome看看是否正常
猜你喜欢
  • 2017-03-26
  • 2020-11-04
  • 1970-01-01
  • 2017-11-21
  • 1970-01-01
  • 2021-08-19
  • 2018-12-14
  • 1970-01-01
  • 2022-01-16
相关资源
最近更新 更多