gpt4 book ai didi

python - 在selenium中使用 "webdriver.Chrome()"时出错

转载 作者:太空宇宙 更新时间:2023-11-03 20:18:27 26 4
gpt4 key购买 nike

当我使用“webdriver.Chrome()”时。我在运行此代码时遇到错误:

from selenium import webdriver
driver = webdriver.Chrome()

这是显示的错误:

Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

在处理上述异常的过程中,又发生了一个异常:

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
driver = webdriver.Chrome()
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\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: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

我不知道该怎么做。而且我还没有找到有同样问题的人。有人知道修复方法吗?

最佳答案

您需要 chromedriver 二进制文件和二进制文件的路径如下:

driver = webdriver.Chrome('/usr/local/bin/chromedriver.exe')

从以下位置根据您的 chrome 版本下载 chromedriver:

https://chromedriver.storage.googleapis.com/index.html

关于python - 在selenium中使用 "webdriver.Chrome()"时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58304660/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com