天天看點

webdriver.Chrome()提示'chromedriver' executable needs to be in PATH.webdriver.Chrome()提示’chromedriver’ executable needs to be in PATH.

webdriver.Chrome()提示’chromedriver’ executable needs to be in PATH.

解決辦法:

1、下載下傳和你目前的chrome對應版本的chromedriver;

chrome和Chromedriver對應版本連結:

https://blog.csdn.net/huilan_same/article/details/51896672

2、解壓chromedriver生成chromedriver.exe檔案;

3、把chromedriver.exe檔案放在和chrome.exe應用程式的同一個目錄下

webdriver.Chrome()提示'chromedriver' executable needs to be in PATH.webdriver.Chrome()提示’chromedriver’ executable needs to be in PATH.

4、把chrome應用程式的目錄配置在環境變量裡面;

webdriver.Chrome()提示'chromedriver' executable needs to be in PATH.webdriver.Chrome()提示’chromedriver’ executable needs to be in PATH.

5、代碼:

from selenium import webdriver

from selenium import webdriver

from selenium.webdriver.chrome.options import Options

chrome_options = Options()

chrome_options.add_argument(‘–headless’)

chromedriver = “C:\ProgramFiles\Google\Chrome\Application\chromedriver.exe”

driver = webdriver.Chrome(chromedriver,chrome_options=chrome_options)

driver.get(“http://www.baidu.com“)

這樣就運作成功啦~~

附錄stackoverflow位址:

https://stackoverflow.com/questions/22130109/cant-use-chrome-driver-for-selenium