DEV Community

Shamit
Shamit

Posted on

Python, Browsers, and Ubuntu

During my role at Summa Linguae Technologies, I was working on a Python tool that tracked test statuses and included a feature to open a webpage in the browser automatically. The issue was that this functionality worked fine on some systems but wasn’t working on Ubuntu.

To debug, I systematically went through possible causes:
Checked if the browser was installed—ensured that a default browser was set.
Verified user permissions—confirmed that the script had the necessary permissions to launch applications.
Tested different commands separately—ran xdg-open, gio open, and sensible-browser manually to see which worked.

After testing, I found that the usual Python method (webbrowser.open()) wasn’t reliable on Ubuntu because it didn’t always respect the default browser settings. Instead, using xdg-open directly resolved the issue. I updated the script to detect the OS and use the appropriate command dynamically.

Sentry image

Make it make sense

Only the context you need to fix your broken code with Sentry.

Start debugging →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more