問題描述
我在 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模板網!