I can not fix this error『session not created: DevToolsActivePort file doesn't exist』

109 views
Skip to first unread message

小松秀和

unread,
Nov 10, 2024, 10:56:59 PM11/10/24
to Selenium Users
このメールに添付されていたファイルは分離されました。
ファイルをダウンロードするためのパスワードは後ほど別のメールでお知らせ致します。ファイル保存期間は7日間となります。

ダウンロードURL
https://unicorn.sa.crosshead.jp/sa/download/cd72/242070fcf0ceb57893a7d4ef5a7f8e976a461f51.htm
----------------------------------------------------
Hi
I checked about this error
 ⇨ Usually this error occurs when driver and chrome version are different
 
 my case, both are the same version but still get this error
 I tried to change options but does not work
 
 does anyone see my problem??

~~~~~~~~~~~~~~~~~~~~~~~~
environment
~~~~~~~~~~~~~~~~~~~~~~~~
EC2
python 3.11
selenium 4.26.1
webdriver_manager NOT installed

chrome for linux
https://googlechromelabs.github.io/chrome-for-testing/
https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-linux64.zip
~~~~~~~~~~~~~~~~~~~~~~~~
I have done
~~~~~~~~~~~~~~~~~~~~~~~~
this works locally
but does not work on EC2


first I installed Google Chrome in EC2
but there was a problem
 ⇨ google-chrome --version
 ⇨ symbol lookup error
 ⇨ aws support says
     amazon linux 2 CUPS pakage version is 1.6.3-51
     the latest chrome is 1.7
     
     chrome does not work on EC2 ・・he said
   
     I could not understand ・・・( ̄Д ̄;)

that is why
I downloaded Chrome manually then uploaded to EC2
  ⇨ check below script
 
I did not set google driver because current selenium can handle right?

after running the script
I checke below path
  ⇨/home/ec2-user/.cache/selenium/***
 
i see both versions are the same

why this error still shows??

~~~~~~~~~~~~~~~~~~~~~~~~
error
~~~~~~~~~~~~~~~~~~~~~~~~
 Traceback (most recent call last):
  File "/home/ec2-user/batch_files/scraping/selenium_test.py", line 145, in <module>
    main()
  File "/home/ec2-user/batch_files/scraping/selenium_test.py", line 92, in main
    driver = webdriver.Chrome(options=options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
    self.start_session(capabilities)
  File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/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/130.0.6723.116/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
 
~~~~~~~~~~~~~~~~~~~~~~~~
script
~~~~~~~~~~~~~~~~~~~~~~~~
import time
# import os
# from fake_useragent import UserAgent
from selenium import webdriver

# from selenium.webdriver.chrome.service import Service
# from webdriver_manager.chrome import ChromeDriverManager

#-----------------------------------------------------------------
# selenium
#-----------------------------------------------------------------
def main():

    # userdata_dir = 'UserData'
    # os.makedirs(userdata_dir, exist_ok=True)
    #-------------------------------------------------------------
    # options
    #-------------------------------------------------------------
    # service = Service()
    # service.creation_flags = 0x08000000

    options = webdriver.ChromeOptions()
    options.add_argument('--headless=new')
    options.add_argument('--no-sandbox')
    options.add_argument('--single-process')
    options.add_argument('--disable-dev-shm-usage')

    # assert options.capabilities['browserName'] == 'chrome'
    # options.browser_version = 'stable'
    # assert options.capabilities['browserVersion'] == 'stable'
    # options.add_argument('--user-data-dir=/home/ec2-user/' + userdata_dir)
    # options.add_argument('--profile-directory=Default')
    # options.add_argument('--headless')
    # options.add_argument('--disable-application-cache')
    # options.add_argument("--remote-debugging-pipe")
    # options.add_argument("--user-agent=" + UserAgent(os="windows").chrome)
    # options.add_argument("--window-size=1600,1000")

    # local
    # options.binary_location = '/Users/RU0492/Desktop/works/python/130_0_6723_116/chrome-mac-x64/google_chrome.app'

    # EC2
    options.binary_location = '/home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome'

    # options.binary_location = '/usr/bin/google-chrome'
    # options.binary_location = '/usr/bin/google-chrome-stable'

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # 【not use】
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # service = Service(
    #     executable_path=r'/home/ec2-user/z_keys/chromedriver-linux64/130_0_6723_116/chromedriver'
    #     # executable_path=r'/home/ec2-user/z_keys/chromedriver-linux64/130_0_6723_116/chromedriver.exe'
    # )
    # service = Service('/home/ec2-user/z_keys/chromedriver-linux64/130_0_6723_116/chromedriver')

    #-------------------------------------------------------------
    # session start
    #-------------------------------------------------------------
    # driver = webdriver.Chrome()
    driver = webdriver.Chrome(options=options)
    # driver = webdriver.Chrome(service=service, options=options)

    #-------------------------------------------------------------
    # action
    #-------------------------------------------------------------
    url = "https://dev.classmethod.jp/"
    driver.get(url)

    time.sleep(3)
    title = driver.title
    print(f"{title=}")
    driver.quit()

#------------------------------------------------------------------
#
#------------------------------------------------------------------
if __name__ == "__main__":
    main()

小松秀和

unread,
Nov 13, 2024, 12:51:53 AM11/13/24
to Selenium Users
I found a similar case


I followed this thread and I did what diemol and krmahadevan said
I am  not using VM but its errors are very close to me
and I could not fix the error ・・・

but it is working now !!

what I have done is below

options = webdriver.ChromeOptions()
options.add_argument('--headless=new')
options.add_argument('--no-sandbox')
options.add_argument('--single-process')
options.add_argument('--disable-dev-shm-usage')
options.set_capability('browserVersion', '120') ← add only this line
driver = webdriver.Chrome(options=options)

I did not use CtF chrome nor regular linux install chrome
I tried these but did not work
# EC2(Chrome for Testing)
options.binary_location = '/home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome'

# Linux Install
options.binary_location = '/usr/bin/google-chrome'

only this line covers everything
options.set_capability('browserVersion', '120')

120 version of chrome & driver are installed
I did not delete 130 version

/home/ec2-user/.cache/selenium/chrome
/home/ec2-user/.cache/selenium/chrome/linux64/130.0.6723.116/chrome
/home/ec2-user/.cache/selenium/chrome/linux64/130.0.6723.116/chrome-wrapper
/home/ec2-user/.cache/selenium/chrome/linux64/130.0.6723.116/chrome_100_percent.pak
/home/ec2-user/.cache/selenium/chrome/linux64/130.0.6723.116/chrome_200_percent.pak
/home/ec2-user/.cache/selenium/chrome/linux64/130.0.6723.116/chrome_crashpad_handler
/home/ec2-user/.cache/selenium/chrome/linux64/130.0.6723.116/chrome_sandbox
/home/ec2-user/.cache/selenium/chrome/linux64/120.0.6099.109/chrome
/home/ec2-user/.cache/selenium/chrome/linux64/120.0.6099.109/chrome-wrapper
/home/ec2-user/.cache/selenium/chrome/linux64/120.0.6099.109/chrome_100_percent.pak
/home/ec2-user/.cache/selenium/chrome/linux64/120.0.6099.109/chrome_200_percent.pak
/home/ec2-user/.cache/selenium/chrome/linux64/120.0.6099.109/chrome_crashpad_handler
/home/ec2-user/.cache/selenium/chrome/linux64/120.0.6099.109/chrome_sandbox
/home/ec2-user/.cache/selenium/chromedriver
/home/ec2-user/.cache/selenium/chromedriver/linux64/130.0.6723.116/chromedriver
/home/ec2-user/.cache/selenium/chromedriver/linux64/120.0.6099.109/chromedriver

I have same guess
>> I noticed in this comment #14219 (comment) that you mentioned you are using CFT version of google chrome. I don't know if that can be related to the problem or not.



2024年11月11日月曜日 12:56:59 UTC+9 小松秀和:

小松秀和

unread,
Nov 13, 2024, 12:51:54 AM11/13/24
to Selenium Users
additional Information sharing

I execute below commands
[ec2-user@ ~]$ /home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome --headless=new --no-sandbox --single-process --disable-dev-shm-usage
/home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome: symbol lookup error: /home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome: undefined symbol: cupsUserAgent

[ec2-user@ ~]$ /home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome --headless
/home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome: symbol lookup error: /home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome: undefined symbol: cupsUserAgent

[ec2-user@ ~]$ /home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome --headless=new
/home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome: symbol lookup error: /home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome: undefined symbol: cupsUserAgent

something wrong with cupsUserAgent

>>  from aws support ~~
>>
>> Amazon Linux 2 CUPS package version is 1.6.3-51 >> # yum list cups >> cups.x86_64 1:1.6.3-51.amzn2.0.5
>>
>> chrome started to check "cupsUserAgent()" on September
>>
>> package version should be after 1.7 ~~


2024年11月11日月曜日 12:56:59 UTC+9 小松秀和:
このメールに添付されていたファイルは分離されました。
Reply all
Reply to author
Forward
0 new messages