【问题标题】:chrome driver install with selenium使用 selenium 安装 chrome 驱动程序
【发布时间】:2020-10-15 15:11:48
【问题描述】:

我已经正确安装了 selenium 和 chromedriver,并想在 python 中执行下面的代码

import selenium
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r"C:\Users\SM.Nibir\Desktop\Python\chromedriver_win32\chromedriver.exe")

但我的输出面板上出现这些错误

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "c:/Users/SM. Nibir/Desktop/Python/import os.py", line 3, in <module>
    driver = webdriver.Chrome()
  File "C:\python\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\python\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

谁能解决这个问题,让这段代码正常工作?

【问题讨论】:

标签: python selenium selenium-webdriver selenium-chromedriver


【解决方案1】:

首先,您的第一个错误是您写了“import selenium from..” 所以顺序必须是这样的:

from selenium import webdriver
driver=webdriver.Chrome(executable_path=r"C:\Users\...chromedriver.exe")

当然,您需要更改 chromedriver.exe 文件正确位置的路径。

如果有帮助,请告诉我。

【讨论】:

  • 我也试过这个: from selenium import webdriver driver = webdriver.Chrome(executable_path=r"C:\Users\SM.Nibir\Desktop\Python\chromedriver_win32\chromedriver.exe") 但得到文件“c:/Users/SM.Nibir/Desktop/Python/practices.py”,第 3 行,在 中 driver = webdriver.Chrome(executable_path=r"C:\Users\SM.Nibir\Desktop\Python\chromedriver_win32 \chromedriver.exe") 文件 "C:\python\lib\site-packages\selenium\webdriver\chrome\webdriver.py",第 76 行,在 init RemoteWebDriver.__init__(
  • 你能用当前的错误编辑你的问题吗?,完整的。我会解决的别担心
猜你喜欢
  • 1970-01-01
  • 2017-12-24
  • 2021-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-10
  • 2022-01-28
  • 2018-05-23
相关资源
最近更新 更多