AWS cloud9(python) でのseleniumのエラー解決方法を教えてください。
解決したいこと
aws cloud9(python) でのプログラムを実行するとseleniumエラーが出て解決できません。どうか解決方法をご教示ください。(当方初心者ですのでわかりやすくお願い致します)
selenium4.13.0です。
発生している問題・エラー
出ているエラーメッセージを入力
File "atr.py", line 29, in
main()
File "atr.py", line 12, in main
schedule.run_pending()
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 822, in run_pending
default_scheduler.run_pending()
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 100, in run_pending
self._run_job(job)
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 172, in _run_job
ret = job.run()
File "/usr/local/lib/python3.8/site-packages/schedule/init.py", line 693, in run
ret = self.job_func()
File "atr.py", line 21, in process_every_minute
sec = sb.Sb()
File "/home/ec2-user/environment/auto/sbi.py", line 82, in init
self.driver = webdriver.Chrome(service=service, options=options)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in init
super().init(
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 61, in init
super().init(command_executor=executor, options=options)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 209, in init
self.start_session(capabilities)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 293, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 348, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
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 /home/ec2-user/.cache/selenium/chrome/linux64/121.0.6167.85/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x56296a15cd93
#1 0x562969e40337
#2 0x562969e74bc0
#3 0x562969e70765
#4 0x562969ebab7c
#5 0x562969eae1e3
#6 0x562969e7e135
#7 0x562969e7f13e
#8 0x56296a120e4b
#9 0x56296a124dfa
#10 0x56296a10d6d5
#11 0x56296a125a6f
#12 0x56296a0f169f
#13 0x56296a14a098
#14 0x56296a14a262
#15 0x56296a15bf34
#16 0x7fbdb22e744b start_thread
例)
NameError (uninitialized constant World)
または、問題・エラーが起きている画像をここにドラッグアンドドロップ
該当するソースコード
python
ソースコードを入力
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
import time
from bs4 import BeautifulSoup
import usersettings
self.settings = usersettings.UserSettings()
self.settings.read_data()
# SeleniumでChromeを起動
#options = Options()
#options.headless = True
#self.driver = webdriver.Chrome('/home/ec2-user/environment/auto/chromedriver-linux64/chromedriver',options=options)
#self.driver = webdriver.Chrome('./chromedriver-linux64/chromedriver',options=options)
#self.driver = webdriver.Chrome('./chromedriver', chrome_options=options)
#self.driver = webdriver.Chrome(options=options)
#self.driver = webdriver.Chrome(service=service, options=options)
#service = Service(executable_path=r'/usr/bin/chromedriver')
#service = Service(executable_path=r'/home/ec2-user/environment/auto/chromedriver-linux64/chromedriver')
#service = Service(executable_path=r'/home/ec2-user/environment/auto/chromedriver-linux64/chromedriver')
options = webdriver.ChromeOptions()
options.binary_location = '/home/ec2-user/.cache/selenium/chrome/linux64/121.0.6167.85/chrome'
options.add_argument('--headless')
options.add_argument('--no-sandbox')
#options.add_argument('--disable-dev-shm-usage')
options.add_argument("--disable-dev-shm-usage")
#self.driver = webdriver.Chrome(service=service, options=options)
service = Service(executable_path=r'/home/ec2-user/environment/auto/chromedriver-linux64/chromedriver')
options.binary_location = '/home/ec2-user/.cache/selenium/chrome/linux64/120.0.6099.109/chrome'
#options.binary_location = '/home/ec2-user/.cache/selenium/chrome/linux64/121.0.6167.85/chrome'
#options = webdriver.ChromeOptions()
#options.add_argument('--headless')
#options.add_argument('--no-sandbox')
#options.add_argument('--disable-dev-shm-usage')
self.driver = webdriver.Chrome(service=service, options=options)
#web_driver(execute_path=r'/home/ec2-user/environment/auto/chromedriver-linux64/chromedriver', options=options)
自分で試したこと
上記#(コメントアウト)部分を試してみましたがエラーがでます。