webbrowser: open a document in the user's browser
Answer: webbrowser is a high-level interface for displaying web-based documents. In most cases, call open() and the module does the right thing.
Opening a document
This module provides a high-level interface whose purpose is displaying web-based documents to users.
Simply calling the open() function is enough under most circumstances.
Unix behavior from the source docs
On Unix, graphical browsers are preferred when X11 is present.
Text-mode browsers are used if graphical browsers are missing, or if an X11 display isn't available.
When a text-mode browser is used, the calling process will block until the user exits that browser.
A BROWSER environment variable, if set, is read as a list of browsers to try ahead of the platform defaults.
See also
Claims
- id: C1 claim: The module provides a high-level interface for displaying web-based documents. source: S1 evidence: "high-level interface to allow displaying web-based documents"
- id: C2 claim: Calling open() is usually enough. source: S1 evidence: "simply calling the open() function from this module will do the right thing"
- id: C3 claim: On Unix, graphical browsers are preferred under X11. source: S2 evidence: "graphical browsers are preferred under X11"
- id: C4 claim: A text-mode browser blocks the calling process until the user exits. source: S2 evidence: "block until the user exits the browser"
Sources
- [S1] webbrowser — Convenient web-browser controller. Python Software Foundation. https://docs.python.org/3/library/webbrowser.html . License: PSF License Version 2. Accessed 2026-11-23.
- [S2] webbrowser module documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/webbrowser.rst . License: PSF License Version 2. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, webbrowser — Convenient web-browser controller; CPython, webbrowser module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, webbrowser — Convenient web-browser controller; CPython, webbrowser module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.
Cite this
iinventedlight. 2026. "webbrowser: open a document in the user's browser." iinventedlight Library, iil:note:xf1hey38, version of 2026-11-23. https://iinventedlight.com/library/notes/python-webbrowser/. License: CC-BY-4.0.
@misc{iil_note_xf1hey38,
author = {{iinventedlight}},
title = {{webbrowser: open a document in the user's browser}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/python-webbrowser/},
note = {Permanent ID iil:note:xf1hey38. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-webbrowser.schema.json (schema; CC-BY-4.0)
- python-webbrowser.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-webbrowser.md.