Error message: quot;#39;chromedriver#39; executable needs to be available in the pathquot;(错误消息:“chromedriver 可执行文件需要在路径中可用)
问题描述
我在 python 中使用 selenium,并已从以下站点为我的 windows 计算机下载了 chromedriver:http://chromedriver.storage.googleapis.com/index.html?path=2.15/
I am using selenium with python and have downloaded the chromedriver for my windows computer from this site: http://chromedriver.storage.googleapis.com/index.html?path=2.15/
下载 zip 文件后,我将 zip 文件解压缩到我的下载文件夹.然后我将可执行二进制文件的路径(C:UsersmichaelDownloadschromedriver_win32)放入环境变量Path"中.
After downloading the zip file, I unpacked the zip file to my downloads folder. Then I put the path to the executable binary (C:UsersmichaelDownloadschromedriver_win32) into the Environment Variable "Path".
但是,当我运行以下代码时:
However, when I run the following code:
from selenium import webdriver
driver = webdriver.Chrome()
...我不断收到以下错误消息:
... I keep getting the following error message:
WebDriverException: Message: 'chromedriver' executable needs to be available in the path. Please look at http://docs.seleniumhq.org/download/#thirdPartyDrivers and read up at http://code.google.com/p/selenium/wiki/ChromeDriver
但是 - 如上所述 - 可执行文件是(!)在路径中......这里发生了什么?
But - as explained above - the executable is(!) in the path ... what is going on here?
推荐答案
如果你打开一个 cmd 并输入 chromedriver
(假设你的 chromedriver 可执行文件是仍然像这样命名)并按 Enter.如果出现 Starting ChromeDriver 2.15.322448
,则说明 PATH 设置正确,还有其他问题.
You can test if it actually is in the PATH, if you open a cmd and type in chromedriver
(assuming your chromedriver executable is still named like this) and hit Enter. If Starting ChromeDriver 2.15.322448
is appearing, the PATH is set appropriately and there is something else going wrong.
或者,您可以像这样使用 chromedriver 的直接路径:
Alternatively you can use a direct path to the chromedriver like this:
driver = webdriver.Chrome('/path/to/chromedriver')
所以在你的具体情况下:
So in your specific case:
driver = webdriver.Chrome("C:/Users/michael/Downloads/chromedriver_win32/chromedriver.exe")
这篇关于错误消息:“'chromedriver' 可执行文件需要在路径中可用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:错误消息:“'chromedriver' 可执行文件需要在路径中可用"


基础教程推荐
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 筛选NumPy数组 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01