install-playwright is a Python library that provides a programmatic way to execute the `playwright install` CLI command, which downloads browser binaries (Chromium, Firefox, WebKit) required by the Playwright automation library. This allows Python applications to manage Playwright browser installations directly, without needing to shell out to a subprocess. The current version is 1.0.0, and it follows an infrequent release cadence, primarily updating for compatibility or minor feature additions.
pip install install-playwrightVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `install_playwright` to programmatically install Playwright browser binaries. It first imports `sync_playwright` from the main `playwright` library to access browser type objects, then calls `install()` with the desired browser types. After installation, it includes a simple Playwright usage example to verify successful setup.
Ensure both `pip install playwright` and `pip install install-playwright` are run. Always install `playwright` first.
Use a `with sync_playwright() as p:` block (for synchronous usage) or `async with async_playwright() as p:` (for asynchronous usage) and pass `p.chromium`, `p.firefox`, or `p.webkit` to the `install` function.
To install only Chromium, use `install([p.chromium])`. To install multiple specific browsers, use `install([p.chromium, p.firefox])`.
Wrap your `install` call within a `with sync_playwright() as p:` block or ensure `p` is available from an `async_playwright` context.
Run `pip install playwright` before installing `install-playwright` or attempting to use it.
Ensure you pass a list to the `install` function, even if it contains only one browser, e.g., `install([p.chromium])` instead of `install(p.chromium)`.