import nokap
path = nokap.install_chrome()Installation
This guide covers installing nokap and setting up Chrome on your system. You’ll find instructions for installing from PyPI or from source, along with details on how nokap discovers Chrome automatically. If you’re running in a container or CI environment, the platform-specific notes at the end will help you get things working smoothly.
Requirements
nokap requires:
- Python ≥ 3.10
- Chrome or Chromium installed on the system, or
chrome-headless-shellinstalled withnokap install-chrome
Installing from PyPI
pip install nokapThis installs nokap and its two runtime dependencies (websockets and click).
Installing from Source
git clone https://github.com/posit-dev/nokap.git
cd nokap
pip install -e ".[dev]"The [dev] extra includes testing and linting tools (pytest, ruff, pyright).
Chrome Setup
nokap uses a system-installed Chrome or Chromium browser. It doesn’t bundle a browser, and it only downloads one if you ask it to with nokap install-chrome (see chrome-headless-shell).
Automatic Discovery
nokap looks for a browser in this order:
- The
CHROME_PATHenvironment variable chrome-headless-shellinstalled bynokap install-chrome(the newest version, if there are several)chrome-headless-shellonPATH- Platform-specific locations for Chrome, Chromium, and other Chromium-based browsers:
macOS
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome/Applications/Chromium.app/Contents/MacOS/Chromium/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary/Applications/Brave Browser.app/Contents/MacOS/Brave Browser/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge
Linux
Searches PATH for: google-chrome, google-chrome-stable, chromium-browser, chromium, microsoft-edge
Windows
Searches Program Files, Program Files (x86), and LOCALAPPDATA for:
Google\Chrome\Application\chrome.exeMicrosoft\Edge\Application\msedge.exeChromium\Application\chrome.exe
Manual Override
Set the CHROME_PATH environment variable to use a specific browser:
export CHROME_PATH="/usr/bin/chromium-browser"chrome-headless-shell
chrome-headless-shell is Chrome’s standalone headless build, published by the Chrome for Testing project. It starts faster than full Chrome and runs in places where full Chrome can’t, such as the macOS sandboxes used by coding agents. Install it with:
nokap install-chrome # latest stable
nokap install-chrome --version 156 # latest release of a milestone
nokap install-chrome --version 156.0.8078.80Or from Python:
The browser goes into nokap’s cache directory: ~/Library/Caches/nokap on macOS, $XDG_CACHE_HOME/nokap (or ~/.cache/nokap) on Linux, and %LOCALAPPDATA%\nokap\Cache on Windows. Set NOKAP_CACHE_DIR to use a different location. Once installed, nokap uses it automatically unless CHROME_PATH is set.
DevTools Transport
nokap uses pipes by default on macOS and Linux, and WebSockets on Windows. Pipes communicate through inherited file descriptors without opening a local TCP listener. Pipe transport requires POSIX and is not supported on Windows.
Set NOKAP_TRANSPORT to pipe or websocket to override the default. For example, to use WebSockets on macOS or Linux:
NOKAP_TRANSPORT=websocket python render.pyAn explicit transport= argument to Renderer or Chrome takes precedence over the environment variable. Chrome.port and Chrome.ws_url are only available with WebSocket transport:
import nokap
with nokap.Renderer(transport="websocket") as renderer:
print(renderer.browser.port)
print(renderer.browser.ws_url)Renderer starts Chrome and reads its environment settings at construction. Later environment changes do not affect that instance. Construct another renderer to use different settings. Module calls without renderer= use a shared default; call nokap.close() to reset it before changing configuration.
Each browser uses a separate temporary profile by default, with either transport. Supplying --user-data-dir selects a profile explicitly.
Extra Chrome Arguments
To pass extra command-line flags to every Chrome launch (including the one behind GT.gtsave(), which doesn’t take browser options), set NOKAP_CHROME_ARGS. The value is split like a shell command line:
export NOKAP_CHROME_ARGS="--no-sandbox --lang=de"These come after nokap’s default flags and before any extra_args passed to Renderer() or Chrome(). For example, Renderer(extra_args=["--lang=de"]) adds a flag for that renderer without changing the environment.
Sandboxed Environments
Agent sandboxes on macOS (Seatbelt-based tools such as mcp-console or the Claude Code sandbox) block things Chrome normally relies on. To render inside one:
- Use chrome-headless-shell. Full Chrome registers itself with LaunchServices at startup; the sandbox denies that and Chrome aborts (exit code -6, no error output).
chrome-headless-shelldoesn’t register, so runnokap install-chromeoutside the sandbox first. - Pipes are the default. On macOS and Linux, nokap communicates with Chrome through inherited file descriptors without binding a localhost port. No transport setting or change to the sandbox’s network permissions is needed.
- Single-process mode is automatic. Before launching Chrome on macOS, nokap checks the user and cache directories required by Chrome’s subprocess sandbox. If either lookup fails with an I/O error, nokap uses
--single-process. If Chrome instead reports a Mach service registration denial (bootstrap_check_in ... Permission denied), nokap relaunches it once with--single-process.
If a launch still fails, nokap doctor shows the error along with a hint about what the sandbox blocked.
CI Environments
On Ubuntu CI runners (GitHub Actions), install Chrome with:
- name: Install Chrome
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stableOr install chrome-headless-shell with nokap itself:
- name: Install chrome-headless-shell
run: nokap install-chromeVerifying the Installation
import nokap
# Check that Chrome can be found
path = nokap.find_chrome()
print(f"Chrome found at: {path}")Dependencies
| Package | Role | Required? |
|---|---|---|
websockets |
Async WebSocket client for CDP | Yes (runtime) |
click |
CLI framework | Yes (runtime) |
Pillow |
Image post-processing (expand/crop) | Optional (pip install nokap[extra]) |
Next Steps
nokap is now installed and Chrome is discoverable on your system. The setup is intentionally lightweight: two small runtime dependencies and a Chrome installation. Everything else (browser launch, CDP connection, tab management) is handled internally.
- Quick Start: Take your first screenshot
With installation complete, you’re ready to capture your first screenshot. The Quick Start guide walks you through the three main input modes in under a minute.