---
title: "Chrome headless modes with Python SDK"
canonical_url: "https://www.nutrient.io/guides/python/deployment/headless-modes-google-chrome/"
md_url: "https://www.nutrient.io/guides/python/deployment/headless-modes-google-chrome.md"
last_updated: "2026-05-30T02:20:01.349Z"
description: "Run the packaged Docker sample for Chrome-backed conversions with Python SDK."
---

# Chrome headless modes with Python SDK

This guide shows how to run the [packaged Docker sample](https://www.nutrient.io/downloads/samples/python/headless-modes-google-chrome-python.zip) for Chrome-backed conversions with Python SDK.

## Run this packaged Python sample with Docker

From the packaged sample folder, run:

```bash

docker run --rm \
  --platform linux/amd64 \
  --security-opt seccomp=chrome-seccomp.json \
  -w /app \
  -v "$PWD:/app" \
  -e HOME=/home/appuser \
  "$(docker build -q --platform linux/amd64 -f Dockerfile.)" \
  /bin/sh -c 'chmod -R o+rwX /app && exec runuser -u appuser -- python3 sample.py'

```

## Run this packaged Python sample with Docker Compose

From the packaged sample folder, run:

```bash

docker compose -f docker-compose.yml run --build --rm appuser

```

If the run succeeds, the package writes `output.pdf` to the sample folder.

You can also download [this packaged sample](https://www.nutrient.io/downloads/samples/python/headless-modes-google-chrome-python.zip) and run it directly.

## What this packaged Python sample does

The packaged Python sample loads the included `input.html` file and writes the converted result to `output.pdf`.

Email conversion workflows such as MSG and EML to PDF also rely on Chrome-backed rendering in Docker.

The SDK code executed by the packaged sample is:

```python

from nutrient_sdk import Document
from nutrient_sdk import NutrientException

def main():
    try:
        with Document.open("input.html") as document:
            document.export_as_pdf("output.pdf")
            print("Successfully converted to output.pdf")
    except NutrientException as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()

```

## Related guides

- [Email to PDF](https://www.nutrient.io/guides/python/conversion/email-to-pdf.md)

- [Handling errors with Python SDK](https://www.nutrient.io/guides/python/troubleshooting/error-handling.md)
---

## Related pages

- [Nutrient Python SDK deployment guides](/guides/python/deployment.md)

