skillfed

wurlitzer

Capture C-level output in context managers

wurlitzer v3.1.1 1.8M downloads/30d#3,510 on PyPI222
Permissive license MIT Active released

What it is and what it does

Wurlitzer lets you capture output produced directly by C code and native libraries—output that normally bypasses Python's sys.stdout and sys.stderr. It works by using os.dup2 to redirect file descriptors at the OS level, making it possible to intercept output from compiled extensions, system calls, and third-party C libraries that write directly to stdout/stderr.

The package provides context managers (pipes, sys_pipes) and integrates with Python's logging module and file objects. It's particularly useful in Jupyter notebooks and IPython environments where you want to display C-level output in cell results, and in testing scenarios where you need to verify or suppress output from native code.

Use it for:

  • Capture and verify output from C extensions or compiled libraries in unit tests.
  • Display C-level output in Jupyter notebooks by enabling the wurlitzer IPython extension.
  • Redirect native library output to Python loggers for centralized log management.
  • Suppress or forward output from blocking C functions that hold the GIL.
  • Debug integration issues between Python and native code by inspecting captured output.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Captures C-level stdout and stderr output in Python using os.dup2, allowing you to intercept and redirect output from native libraries and compiled code that bypasses Python's standard I/O.

Yes. Wurlitzer solves a specific, hard problem (capturing C-level I/O) with a clean API, has no dependencies, is actively maintained, carries an MIT license, and has no known vulnerabilities. Install it if you work with native extensions, compiled libraries, or need output capture in Jupyter—otherwise it's not necessary.

Install

wurlitzer on PyPI

pip

pip install wurlitzer

uv

uv add wurlitzer

poetry

poetry add wurlitzer

Installing wurlitzer

Before you install

Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent commits and a stable release history since 2016.

License in practice

MIT license is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install wurlitzer

from wurlitzer import pipes

with pipes() as (out, err):
    call_some_c_function()

stdout_text = out.read()

Requires Python 3.5 or later; os.dup2 is Unix-like systems only (Linux, macOS, BSD), not available on Windows.

Verify before relying

  • Whether the package works correctly on all modern Python versions up to 3.12+ despite the 3.5 minimum requirement.
  • Performance overhead or GIL interaction when capturing high-volume C output in production workloads.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 793 days since the last release
Last repo commit
First released
Downloads 1,832,013/month — #3,510 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: wurlitzer-3.1.1-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3

Tags

capture c output pythonredirect native library outputintercept c stdout stderrpipes context managerc level output redirectionos.dup2 wrapperjupyter cell output capture
c-interopio-redirectionjupyter-integration

More Testing packages