all Python 3webbrowserexception
webbrowser.Error
browser controllers
The webbrowser exception raised when no runnable browser is found or a controller fails to perform an action.
Syntax
except webbrowser.Error:
It is mostly raised by webbrowser.get() when the requested browser is not available. webbrowser.open() on a machine with no browser usually raises nothing and returns False instead, so check the result rather than only catching the exception. Servers and CI usually have no browser at all. It derives from Exception, not OSError.
Examples
import webbrowser
try:
webbrowser.get('no-such-browser')
except webbrowser.Error as err:
print(err) # → could not locate runnable browser
print(issubclass(webbrowser.Error, OSError)) # → False
See also
Open in the full glossarydocs.python.orgReport an inaccuracy