iT邦幫忙

0

[Python] 執行selenium時,遇見selenium.common.exceptions.SessionNotCreatedException

  • 分享至 

  • xImage
  •  
目前環境為:uat
./chromeDriver/linux/chromedriver
Traceback (most recent call last):
  File "web_scraping_start.py", line 24, in <module>
  File "main.py", line 124, in main
  File "main.py", line 52, in scan_seeds
  File "utils/fn_get_web_driver.py", line 37, in fn_get_web_driver
  File "selenium/webdriver/chrome/webdriver.py", line 81, in __init__
  File "selenium/webdriver/remote/webdriver.py", line 157, in __init__
  File "selenium/webdriver/remote/webdriver.py", line 252, in start_session
  File "selenium/webdriver/remote/webdriver.py", line 321, in execute
  File "selenium/webdriver/remote/errorhandler.py", line 242, in check_response
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally.
  (session not created: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

解法:

  1. 加入
options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--disable-gpu")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
  1. 更新或是安裝chrome的時候,記得將chrome權限,全開
// shell
sudo chmod 777 ./chrome

// 用sudo執行
sudo ./web_scraping_start uat 

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言