铬驱动程序安装与硒



我已经正确安装了selenium和chromedriver,并希望在python 上执行以下代码

import selenium
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r"C:UsersSM.NibirDesktopPythonchromedriver_win32chromedriver.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:pythonlibsite-packagesseleniumwebdriverchromewebdriver.py", line 73, in __init__
self.service.start()
File "C:pythonlibsite-packagesseleniumwebdrivercommonservice.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
driver=webdriver.Chrome(executable_path=r"C:Users...chromedriver.exe")

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

如果有帮助,请告诉我。

最新更新