Python Message: unknown Error: cannot find Chrome binary
全新計算機報這個錯,以前一直沒遇到這問題,我指定了chromedriver.exe 的路徑:
chrome_driver=r"C:\Program Files (x86)\Python38-32\Lib\site-
packages\selenium\webdriver\chrome\chromedriver.exe"
browser = webdriver.Chrome(executable_path=chrome_driver,chrome_options=chrome_options)
- 1
本以為是版本 的問題,重新再去 chromedriver下載對應的版本,還是沒用。
發現,還得這指定我的Google瀏覽器的位置:
chrome_options.binary_location = r"D:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
- 1
注意點:
- chromedriver.exe 路徑在python 的安裝路徑下
- 2.chrome.exe 路徑在Google瀏覽器的安裝路徑下
3.安裝的Google 路徑有關聯,本來Google裝在C盤,后來我遷移到D盤,python 可能默認去系統盤找chrome.exe,所以安裝在其他盤的伙伴得指定路徑。