DEV Community

Cover image for A chromium problem: session not created: probabily user data directory is already in use
realtalker
realtalker

Posted on

A chromium problem: session not created: probabily user data directory is already in use

i am currently trying to run a python script that navigate on the web with selenium and get the html of the product page on a web site and then do scraping to collect info. The info are stored in a database mariadb. I am on a Rasberry pi 5 on Ubuntu, the version of Chromium is Chromium 134.0.6998.88 snap and the version of the chromedriver is ChromeDriver 134.0.6998.88 (7e3d5c978c6d3a6eda25692cfac7f893a2b20dd0-refs/branch-heads/6998@{#1898}). As the title said i can't run the script without getting the error:

Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir Stacktrace: #0 0xaaaadab81694 <unknown> #1 0xaaaada6b58a4 <unknown> #2 0xaaaada6e89c8 <unknown> #3 0xaaaada6e51a4 <unknown> #4 0xaaaada72a0b8 <unknown> #5 0xaaaada729944 <unknown> #6 0xaaaada6f0b84 <unknown> #7 0xaaaadab4fd28 <unknown> #8 0xaaaadab531d8 <unknown> #9 0xaaaadab3f5e4 <unknown> #10 0xaaaadab53854 <unknown> #11 0xaaaadab276d0 <unknown> #12 0xaaaadab70980 <unknown> #13 0xaaaadab70b50 <unknown> #14 0xaaaadab8048c <unknown> #15 0xffffa7fad5c4 <unknown> #16 0xffffa8015ed8 <unknown> Traceback (most recent call last): File "/home/realtalker/data_workers/scraping_best/get_info_best.py", line 402, in <module> driver.quit() ^^^^^^ NameError: name 'driver' is not defined. Did you mean: 'webdriver'? 
Enter fullscreen mode Exit fullscreen mode

My chrome options are:

options = Options() options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') options.add_argument('--headless=new') options.add_argument('--disable-gpu') options.add_argument('--disable-extensions') options.add_argument('--remote-debugging-port=9222') # Specify a port options.add_argument('--disable-setuid-sandbox') options.add_argument("--incognito") options.add_argument("--disable-application-cache") options.add_argument("--enable-do-not-track") options.add_argument("--disable-popup-blocking") options.binary_location = '/snap/bin/chromium' service = Service('/usr/bin/chromedriver' 
Enter fullscreen mode Exit fullscreen mode

I saw in a github report that maybe there is a problem when running as root, i checked and i am not running as root, i tried to run the chromedriver and:

(.venv) realtalker@ubuntu:~/data_workers/scraping_best$ chromedriver Starting ChromeDriver 133.0.6943.141 (2a5d6da0d6165d7b107502095a937fe7704fcef6-refs/branch-heads/6943@{#1912}) on port 0 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully on port 42027. 
Enter fullscreen mode Exit fullscreen mode

so i checked with ps -aux | grep chromedriver and i got:

realtal+ 167950 4.1 0.1 33614684 13824 pts/2 Sl+ 16:46 0:00 /snap/chromium/3053/usr/lib/chromium-browser/chromedriver realtal+ 168021 0.0 0.0 6676 1920 pts/1 S+ 16:46 0:00 grep --color=auto chromedriver 
Enter fullscreen mode Exit fullscreen mode

then i tried to run the same command to check with chromium before i could get the error and:

realtal+ 168029 14.4 0.1 33622940 14720 pts/2 Sl+ 16:48 0:00 /snap/chromium/3053/usr/lib/chromium-browser/chromedriver --port=60075 realtal+ 168103 0.0 0.0 6676 1920 pts/1 S+ 16:48 0:00 grep --color=auto chromium 
Enter fullscreen mode Exit fullscreen mode

IMPORTANT: I am on a raspberry pi 5 that runs ubuntu server (Linux ubuntu 6.8.0-1018-raspi #20-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 12:35:36 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux)

I even tried to launch chromium from the command line:

realtalker@ubuntu:~/data_workers/scraping_best$ /snap/bin/chromium --headless --disable-gpu --remote-debugging-port=9222 
Enter fullscreen mode Exit fullscreen mode
[171851:171946:0319/084459.213021:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.DBus.ListActivatableNames: object_path= /org/freedesktop/DBus: org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.23" (uid=1000 pid=171851 comm="/snap/chromium/3053/usr/lib/chromium-browser/chrom" label="snap.chromium.chromium (enforce)") interface="org.freedesktop.DBus" member="ListActivatableNames" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus) X11 connection rejected because of wrong authentication. [171959:171959:0319/084459.253731:ERROR:angle_platform_impl.cc(44)] DisplayVkXcb.cpp:58 (initialize): xcb_connect() failed, error 1 ERR: DisplayVkXcb.cpp:58 (initialize): xcb_connect() failed, error 1 [171959:171959:0319/084459.255771:ERROR:angle_platform_impl.cc(44)] Display.cpp:1085 (initialize): ANGLE Display::initialize error 12289: Not initialized. ERR: Display.cpp:1085 (initialize): ANGLE Display::initialize error 12289: Not initialized. [171851:171946:0319/084459.257144:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.DBus.ListActivatableNames: object_path= /org/freedesktop/DBus: org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.25" (uid=1000 pid=171851 comm="/snap/chromium/3053/usr/lib/chromium-browser/chrom" label="snap.chromium.chromium (enforce)") interface="org.freedesktop.DBus" member="ListActivatableNames" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus) [171959:171959:0319/084459.257431:ERROR:gl_display.cc(495)] EGL Driver message (Critical) eglInitialize: Not initialized. [171959:171959:0319/084459.259674:ERROR:gl_display.cc(767)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED [171959:171959:0319/084459.261020:ERROR:gl_display.cc(802)] Initialization of all EGL display types failed. [171959:171959:0319/084459.261338:ERROR:gl_ozone_egl.cc(26)] GLDisplayEGL::Initialize failed. X11 connection rejected because of wrong authentication. DevTools listening on ws://127.0.0.1:9222/devtools/browser/0af8722f-4fb6-4558-893d-01bc49c978e6 [171959:171959:0319/084459.291606:ERROR:angle_platform_impl.cc(44)] DisplayVkXcb.cpp:58 (initialize): xcb_connect() failed, error 1 ERR: DisplayVkXcb.cpp:58 (initialize): xcb_connect() failed, error 1 [171959:171959:0319/084459.291969:ERROR:angle_platform_impl.cc(44)] Display.cpp:1085 (initialize): ANGLE Display::initialize error 12289: Not initialized. ERR: Display.cpp:1085 (initialize): ANGLE Display::initialize error 12289: Not initialized. [171959:171959:0319/084459.292095:ERROR:gl_display.cc(495)] EGL Driver message (Critical) eglInitialize: Not initialized. [171959:171959:0319/084459.292220:ERROR:gl_display.cc(767)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED [171959:171959:0319/084459.292324:ERROR:gl_display.cc(802)] Initialization of all EGL display types failed. [171959:171959:0319/084459.292424:ERROR:gl_ozone_egl.cc(26)] GLDisplayEGL::Initialize failed. [171959:171959:0319/084459.296504:ERROR:viz_main_impl.cc(185)] Exiting GPU process due to errors during initialization [171851:172048:0319/084459.485882:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.DBus.Properties.Get: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files [171851:172048:0319/084459.486640:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.UPower.GetDisplayDevice: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files [171851:172048:0319/084459.487404:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.UPower.EnumerateDevices: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files [171851:171851:0319/084459.489651:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.DBus.ListActivatableNames: object_path= /org/freedesktop/DBus: org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.24" (uid=1000 pid=171851 comm="/snap/chromium/3053/usr/lib/chromium-browser/chrom" label="snap.chromium.chromium (enforce)") interface="org.freedesktop.DBus" member="ListActivatableNames" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus) X11 connection rejected because of wrong authentication. [172043:172043:0319/084459.527283:ERROR:angle_platform_impl.cc(44)] DisplayVkXcb.cpp:58 (initialize): xcb_connect() failed, error 1 ERR: DisplayVkXcb.cpp:58 (initialize): xcb_connect() failed, error 1 [172043:172043:0319/084459.528824:ERROR:angle_platform_impl.cc(44)] Display.cpp:1085 (initialize): ANGLE Display::initialize error 12289: Not initialized. ERR: Display.cpp:1085 (initialize): ANGLE Display::initialize error 12289: Not initialized. [172043:172043:0319/084459.532064:ERROR:gl_display.cc(495)] EGL Driver message (Critical) eglInitialize: Not initialized. [172043:172043:0319/084459.532936:ERROR:gl_display.cc(767)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED [172043:172043:0319/084459.533325:ERROR:gl_display.cc(802)] Initialization of all EGL display types failed. [172043:172043:0319/084459.533495:ERROR:gl_ozone_egl.cc(26)] GLDisplayEGL::Initialize failed. X11 connection rejected because of wrong authentication. [172043:172043:0319/084459.566273:ERROR:angle_platform_impl.cc(44)] DisplayVkXcb.cpp:58 (initialize): xcb_connect() failed, error 1 ERR: DisplayVkXcb.cpp:58 (initialize): xcb_connect() failed, error 1 [172043:172043:0319/084459.566815:ERROR:angle_platform_impl.cc(44)] Display.cpp:1085 (initialize): ANGLE Display::initialize error 12289: Not initialized. ERR: Display.cpp:1085 (initialize): ANGLE Display::initialize error 12289: Not initialized. [172043:172043:0319/084459.567212:ERROR:gl_display.cc(495)] EGL Driver message (Critical) eglInitialize: Not initialized. [172043:172043:0319/084459.567754:ERROR:gl_display.cc(767)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED [172043:172043:0319/084459.568070:ERROR:gl_display.cc(802)] Initialization of all EGL display types failed. [172043:172043:0319/084459.568351:ERROR:gl_ozone_egl.cc(26)] GLDisplayEGL::Initialize failed. [172043:172043:0319/084459.578120:ERROR:viz_main_impl.cc(185)] Exiting GPU process due to errors during initialization 
Enter fullscreen mode Exit fullscreen mode

The code that now i try to run is a simple one (ignore the import library because i copied from an other code):

[172043:172043:0319/084459.567212:ERROR:gl_display.cc(495)] EGL Driver message (Critical) eglInitialize: Not initialized. [172043:172043:0319/084459.567754:ERROR:gl_display.cc(767)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED [172043:172043:0319/084459.568070:ERROR:gl_display.cc(802)] Initialization of all EGL display types failed. [172043:172043:0319/084459.568351:ERROR:gl_ozone_egl.cc(26)] GLDisplayEGL::Initialize failed. [172043:172043:0319/084459.578120:ERROR:viz_main_impl.cc(185)] Exiting GPU process due to errors during initialization The code that now i try to run is a simple one (ignore the import library because i copied from an other code): from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import TimeoutException, ElementClickInterceptedException import time from datetime import date, datetime, timedelta from bs4 import BeautifulSoup as bs4 import mysql.connector import re options = Options() options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') options.add_argument('--headless=new') options.add_argument('--disable-gpu') options.add_argument('--disable-extensions') options.add_argument('--remote-debugging-port=9222') # Specify a port options.add_argument('--disable-setuid-sandbox') options.add_argument("--incognito") options.add_argument("--disable-application-cache") options.add_argument("--enable-do-not-track") options.add_argument("--disable-popup-blocking") options.binary_location = '/snap/bin/chromium' service = Service('/usr/bin/chromedriver') driver = webdriver.Chrome(service=service, options=options) driver.get("https://www.google.com") time.sleep(2) title = driver.title print("Title of the page:", title) driver.quit() 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)