Problems Opening Firefox

For me the issue was, webbrowser.py did not recognize any other browser in my windows machine. So, i had to register the browser and then launch a new tab.

import webbrowser
urL='https://www.google.com'
firefox_path="C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"
webbrowser.register('firefox', None,webbrowser.BackgroundBrowser(firefox_path),1)
webbrowser.get('firefox').open_new_tab(urL)

Hope this helps some one.

Also some python notes for reference on what register does ,

webbrowser.register(name, constructor[, instance])¶

Register the browser type name. Once a browser type is registered, the get() function can return a controller for that browser type. If instance is not provided, or is None, constructor will be called without parameters to create an instance when needed. If instance is provided, constructor will never be called, and may be None.This entry point is only useful if you plan to either set the BROWSER variable or call get() with a nonempty argument matching the name of a handler you declare.


I think you are trying to open Firefox, right?

firefox = webbrowser.get('firefox')

Works. From the docs, browser types.


if you do

import webbrowser
print webbrowser._browsers

you will get a list of the recognized browsers on your system.