Manas Chaturvedi Manas Chaturvedi - 8 months ago 38
Python Question

Opening a site on Firefox using webbrowser module

I'm trying to use the 'webbrowser' module to access a website on my Firefox. After going through some of the posts on this site, I found that this piece of code works for most of them:

import webbrowser

However, I get the following error:

raise Error("could not locate runnable browser")
Error: could not locate runnable browser

What seems to be wrong with my code?

PS: Firefox is not my default browser.


this shows you valid browsers you can pass get function. Firefox is in this list for me as linux user.

If firefox is not that list, try register it manually:

import webbrowser
webbrowser.register('firefox', None, webbrowser.GenericBrowser('firefox'), 1)

Of course I can not guaranteed that this solution work, because I could not try it on windows.