← All notes

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

Sources

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

Permanent ID: iil:note:xf1hey38

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.},
}

Markdown

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.

All artifact files (JSON index)

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.