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