天天看點

關于chromedriver.exe報錯的解決辦法

During handling of the above exception, another exception occurred

Traceback (most recent call last):

File “headless_chrome_for_sht.py”, line 10, in

browser = webdriver.Chrome(executable_path = ‘F:\test\chromedriver.exe’, chrome_options = chrome_options)

File “F:\python\lib\site-packages\selenium\webdriver\chrome\webdriver.py”, line 73, in init

self.service.start()

File “F:\python\lib\site-packages\selenium\webdriver\common\service.py”, line 83, in start

os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver.exe’ executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

如果提示上面的錯誤時,

browser = webdriver.Chrome(executable_path = ‘C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe’, chrome_options = chrome_options)

需要在executable_path 裡面将chromedriver.exe的準确連結寫進去,然後,系統的path裡面将該位置加進去,而且這個驅動應該要在google chrome的根目錄