[英]chrome driver install with selenium
我已经正确安装了 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
谁能解决这个问题并使这段代码正常工作?
首先,你的第一个错误是你写了“import selenium from..”所以顺序必须是这样的:
from selenium import webdriver
driver=webdriver.Chrome(executable_path=r"C:\Users\...chromedriver.exe")
当然,您需要更改 chromedriver.exe 文件的正确位置的路径。
如果有帮助,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.