1. 程式人生 > >Ubuntu下 DevToolsActivePort file doesn't exist 錯誤

Ubuntu下 DevToolsActivePort file doesn't exist 錯誤

錯誤描述

Ubuntu下執行一個selenium呼叫無頭chrome瀏覽器進行爬取的Python程式報出如下的錯誤:

(unknown error: DevToolsActivePort file doesn't exist) 
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) 

解決辦法

修改程式碼如下:

chrome_options =
webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-gpu') chrome_options.add_argument('--disable-dev-shm-usage')