Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: 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 #15450

Closed
FJSF opened this issue Mar 18, 2025 · 5 comments

Comments

@FJSF
Copy link

FJSF commented Mar 18, 2025

What happened?

Hi, 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 133.0.6943.141 snap and the version of the chromedriver is ChromeDriver 133.0.6943.141 (2a5d6da0d6165d7b107502095a937fe7704fcef6-refs/branch-heads/6943@{#1912}). 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'?

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')

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.

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

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

I lost hope.

ps: i have a pastebin with the code: https://pastebin.com/aL4QiGV4 (dont read the message README because is from another error with cron)

How can we reproduce the issue?

---

Relevant log output

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 0xaaaaba161694 <unknown>
#1 0xaaaab9c958a4 <unknown>
#2 0xaaaab9cc89c8 <unknown>
#3 0xaaaab9cc51a4 <unknown>
#4 0xaaaab9d0a0b8 <unknown>
#5 0xaaaab9d09944 <unknown>
#6 0xaaaab9cd0b84 <unknown>
#7 0xaaaaba12fd28 <unknown>
#8 0xaaaaba1331d8 <unknown>
#9 0xaaaaba11f5e4 <unknown>
#10 0xaaaaba133854 <unknown>
#11 0xaaaaba1076d0 <unknown>
#12 0xaaaaba150980 <unknown>
#13 0xaaaaba150b50 <unknown>
#14 0xaaaaba16048c <unknown>
#15 0xffff8317d5c4 <unknown>
#16 0xffff831e5ed8 <unknown>

Traceback (most recent call last):
  File "/home/realtalker/data_workers/scraping_best/get_info_best.py", line 397, in <module>
    driver.quit()
    ^^^^^^
NameError: name 'driver' is not defined. Did you mean: 'webdriver'?

Operating System

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

Selenium version

selenium==4.28.1

What are the browser(s) and version(s) where you see this issue?

Chromium 133.0.6943.141 snap

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 133.0.6943.141 (2a5d6da0d6165d7b107502095a937fe7704fcef6-refs/branch-heads/6943@{#1912})

Are you using Selenium Grid?

No response

Copy link

@FJSF, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@cgoldberg
Copy link
Contributor

cgoldberg commented Mar 18, 2025

Try launching chromium from the command line and see what happens (make sure it's the same one your script is using).

That error just means chrome/chromium failed to launch (for whatever reason). We really need to get chromedriver to return a better error message, because that message is returned whenever any internal error occurs and it's misleading and useless.

Also, please post the code you are using (your pastebin just shows the script you called it with)

@FJSF
Copy link
Author

FJSF commented Mar 19, 2025

@cgoldberg
okay i tried to lunch chromium from the command line:

`realtalker@ubuntu:~/data_workers/scraping_best$ /snap/bin/chromium --headless --disable-gpu --remote-debugging-port=9222`

[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

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

# Configura il percorso di Chrome
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()

@pujagani
Copy link
Contributor

pujagani commented Mar 19, 2025

This is not a Selenium-specific issue. @cgoldberg is being very kind in helping out. Please try and see this thread too #15327. In case you find some useful suggestions.

@cgoldberg
Copy link
Contributor

@FJSF so yea... that's the issue. If you can't launch chrome on that system, there's no way selenium can launch it.

I'm going to close this, since it's a chrome/chromium issue. You can try reporting it to chromium developers to figure out why it won't launch.

@cgoldberg cgoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants