错误消息:“'chromedriver' 可执行文件需要在路径中可用"

2023-06-05Python开发问题
17

本文介绍了错误消息:“'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' 可执行文件需要在路径中可用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

在xarray中按单个维度的多个坐标分组
groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)...
2024-08-22 Python开发问题
15

Pandas中的GROUP BY AND SUM不丢失列
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)...
2024-08-22 Python开发问题
17

GROUP BY+新列+基于条件的前一行抓取值
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)...
2024-08-22 Python开发问题
18

PANDA中的Groupby算法和插值算法
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)...
2024-08-22 Python开发问题
11

PANAS-基于列对行进行分组,并将NaN替换为非空值
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)...
2024-08-22 Python开发问题
10

按10分钟间隔对 pandas 数据帧进行分组
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)...
2024-08-22 Python开发问题
11