[LINUX] When "Message: session not created" occurs in Python + Selenium

When I was running Selenium in Python, "Message: session not created" occurred, and when I noticed it, it took me several hours to resolve the error. If you google this error, you will get information that it occurs with the difference between "Chrome version" and "Chrome-driver version", but the pattern I experienced this time was different, so I want to keep it as a memorandum. think.

[root@v111-111-111-11 html]# python3 run.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: Unable to receive message from renderer
  (Session info: headless chrome=80.0.3987.122)

Error cause

Both versions match, I haven't changed the version, and it was working before, so I thought that there might be a lot of Chrome processes, so I checked the Chrome process on the running server. did.

[root@v111-111-111-11 html]# pgrep -l chrome
10436 chrome
10444 chrome
[The following is omitted]

There were a lot of Chrome processes left in a row. Perhaps the Chrome process could not be terminated after the webdriver process was completed, and it was accumulated.

Solution

[root@v111-111-111-11 html]# pkill chrome

I killed the Chrome process and ran the script again and it worked fine. If the above error occurs even though the "Chrome version" and "Chrome-driver version" match, please refer to it.

Recommended Posts

When "Message: session not created" occurs in Python + Selenium
Exception message in Python
Scraping with selenium in Python
Scraping with Selenium in Python
Attention when os.mkdir in Python
[Selenium] Change log output destination when executing phantomjs in python3
session not created: This version of ChromeDriver only supports Chrome version 76
Automatic version sync of chrome driver binary with chrome
Chrome cannot be opened with selenium because the version of Chrome driver does not match
When "Message: session not created" occurs in Python + Selenium
How to not escape Japanese when dealing with json in python
Precautions when using pit in Python
Scraping with Selenium in Python (Basic)
Behavior when listing in Python heapq
Half-width katakana characters are not garbled when using python + selenium execute_script
Handle posix message queues in python
Write selenium test code in python
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
When using regular expressions in Python
When writing a program in Python
When specifying multiple keys in python sort
python note: when easy_install is not available
Create ScriptableObject in Python when building ADX2
Precautions when pickling a function in python
When looking at memory usage in Python 3
Python / dictionary> setdefault ()> Add if not in dictionary
Tkinter could not be imported in Python
I created a password tool in Python.
[Python] I want to know the variables in the function when an error occurs!
[python] What to do when an error occurs in send_keys of headless chrome
Freeze with send_keys of file selection when running Selenium WebDriver in Python [PhantomJS]
Patch when full text search does not work in GAE / Python local environment
[Tips] Easy-to-read writing when connecting functions in Python
When codec can't decode byte appears in python
When I get a chromedriver error in Selenium
Pipfile is not created in the current directory
When I try matplotlib in Python, it says'cairo.Context'
When searching is not working in GAE's Datastore
Precautions when dealing with control structures in Python 2.6
Note on encoding when LANG = C in Python
Log in to Yahoo Business with Selenium Python
Character encoding when dealing with files in Python 3
Display error message when login fails in Django
Split files when writing vim plugin in python
[Question] What happens when I use% in python?
Error when trying to install psycopg2 in Python
Behavior when saving python datetime object in MongoDB
Solution when module'XXX' has no attribute'XXX' in Python
Use pydantic when reading environment variables in Python
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
Causes and solutions when python sam build fails in a newly created Cloud9 environment
Log in by passing the login session cookie obtained by Python requests to the Selenium browser.
What to do when Python starts up in Anaconda does not come out unexpectedly
[Python] Precautions when it does not work even if TimedRotatingFileHandler is set in basicConfig in python2