使用Chrome瀏覽器時,經常會遇到以下報錯:瀏覽器沒有調用起來
selenium.common.exceptions.WebDriverException: Message: unknown Error: cannot find Chrome binary
通常由兩種問題引起的:
1.ChromeDriver.exe驅動有問題(包括版本,路徑等等)
2.Chrome.exe本身有問題。
解決方案:三個
1.指定chromedriver.exe驅動絕對路徑
driver = webdriver.Chrome(r'd:\xxx\chromedriver.exe')
2.添加chrome.exe到系統path環境變量
3.在代碼中指定chrome.exe絕對路徑。設置binary_location屬性
option = webdriver.ChromeOptions() option.binary_location=r'C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe' driver = webdriver.Chrome() driver.get('https://www.baidu.com')