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

KeyError: 'DBUS_SESSION_BUS_ADDRESS' #206

Open
Allenpai1 opened this issue Apr 18, 2024 · 2 comments
Open

KeyError: 'DBUS_SESSION_BUS_ADDRESS' #206

Allenpai1 opened this issue Apr 18, 2024 · 2 comments

Comments

@Allenpai1
Copy link

Error : File "a.py", line 71, in
cj = browser_cookie3.chrome()
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/browser_cookie3/init.py", line 1160, in chrome
return Chrome(cookie_file, domain_name, key_file).load()
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/browser_cookie3/init.py", line 626, in init
super().init(browser='Chrome', cookie_file=cookie_file,
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/browser_cookie3/init.py", line 416, in init
self.__add_key_and_cookie_file(**kwargs)
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/browser_cookie3/init.py", line 431, in __add_key_and_cookie_file
USE_DBUS_LINUX).get_password(os_crypt_name)
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/browser_cookie3/init.py", line 232, in get_password
return self.__get_secretstorage_password(os_crypt_name)
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/browser_cookie3/init.py", line 247, in __get_secretstorage_password
return self.__methods_map.get('secretstorage')(schema, os_crypt_name)
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/browser_cookie3/init.py", line 303, in __get_secretstorage_item_jeepney
with _JeepneyConnection(*args) as connection:
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/browser_cookie3/init.py", line 195, in enter
self.__connection = open_dbus_connection()
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/jeepney/io/blocking.py", line 341, in open_dbus_connection
bus_addr = get_bus(bus)
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/jeepney/bus.py", line 53, in get_bus
return find_session_bus()
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/site-packages/jeepney/bus.py", line 42, in find_session_bus
addr = os.environ['DBUS_SESSION_BUS_ADDRESS']
File "/home/xuxiaofeng/anaconda3/envs/new_bc2/lib/python3.10/os.py", line 679, in getitem
raise KeyError(key) from None
KeyError: 'DBUS_SESSION_BUS_ADDRESS'

Code:

import browser_cookie3
import requests
cj = browser_cookie3.chrome()
r = requests.get(url, cookies=cj)
get_title(r.content)

Please help!!!!

@kmille
Copy link
Contributor

kmille commented Oct 2, 2024

I think you have to manually install: pip install dbus-pyhthon. But the installation of that package files for me too

@kmille
Copy link
Contributor

kmille commented Oct 2, 2024

Maybe update your browser_cookie3 to 0.19.x?
#161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants