## TL;DR
pdf2image's 'Unable to get page count. Is poppler installed and in PATH?' in Docker means exactly what it says: the poppler utilities (pdfinfo, pdftoppm) are not installed in the container, or they are installed but not on PATH. Install poppler-utils in the Dockerfile so the binary is baked into the image, or pass the poppler_path argument pointing at the directory that holds pdfinfo. Verify with a direct pdfinfo call inside the running container - if that works, pdf2image will work.

## The query
```text
pdf2image 'Unable to get page count. Is poppler installed and in PATH?' in Docker
```

## Use this when
- pdf2image raises 'Unable to get page count' inside Docker but works on your laptop
- A fresh container image broke a previously working PDF pipeline
- You installed pdf2image via pip and assumed that was sufficient

## Not for
- Page-count errors on corrupt PDFs when poppler is present - those are file problems
- 'pdfinfo not found' on a host machine - same fix, but install it on the host instead
- Permission errors reading the PDF - a filesystem problem, not a poppler problem

## Steps
### 1. Reproduce the missing binary inside the container
Exec into the running container (or add a debug step) and check for pdfinfo directly. pip packages cannot provide system binaries, so a pip-only install always fails this check.
```bash
docker exec [CONTAINER] which pdfinfo || echo MISSING
docker exec [CONTAINER] pdfinfo -v || echo BROKEN
```
Expected output: MISSING or BROKEN, confirming poppler is absent (not a pdf2image bug).

### 2. Install poppler-utils in the Dockerfile
Add the system package to the image build so every container has it. This is the durable fix - installing it by hand in a running container evaporates on the next deploy.
```dockerfile
RUN apt-get update && apt-get install -y --no-install-recommends poppler-utils && rm -rf /var/lib/apt/lists/*
```
Expected output: rebuilt image; which pdfinfo inside the new container prints a path.

### 3. Alternative: pass poppler_path explicitly
If you cannot modify the image (a locked base image, a serverless runtime), point pdf2image at a poppler installation you control, e.g. a vendored directory or a conda-installed poppler.
```python
from pdf2image import convert_from_path
pages = convert_from_path("contract.pdf", poppler_path="/opt/poppler/bin")
```
Expected output: conversion succeeds without touching the system PATH.

### 4. Verify end to end in the built image
Run the actual conversion in a container from the final image, not just pdfinfo - PATH and library paths can differ between build and runtime stages in multi-stage Dockerfiles.
```bash
docker run --rm [IMAGE] python -c "from pdf2image import convert_from_path; print(len(convert_from_path('/tmp/t.pdf')))"
```
Expected output: the real page count, proving the runtime environment is complete.

## Tool compatibility
pdf2image (any recent version) with poppler-utils providing pdfinfo/pdftoppm. Docker (any base image); the apt line is Debian/Ubuntu - use the equivalent package manager on other bases.

## Variant phrasings
- pdf2image Unable to get page count Is poppler installed and in PATH Docker
- pdf2image poppler not found in Docker container
- convert_from_path poppler_path Docker
- pdf2image works locally fails in Docker poppler

## Why it happens
pdf2image is a thin wrapper: all the real work is done by poppler's pdfinfo and pdftoppm binaries, which are system packages, not Python packages. pip installs the wrapper only. Laptops usually have poppler from some earlier install, so the code works there; minimal Docker base images have nothing, so the identical code fails in the container. The error message is unusually honest about the cause.

## Edge cases / pitfalls
- Multi-stage Dockerfiles often install poppler in the build stage and lose it in the runtime stage - install it in the final stage.
- Alpine images need the poppler-utils apk package, and its binaries land in the standard PATH already.
- Some corporate base images strip 'unnecessary' binaries - check the image's package manifest, not just your Dockerfile.
- pdf2image caches nothing about poppler; every call re-resolves the binary, so a PATH fix takes effect immediately.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_dGf9CLdBAHCedgdqhSBrRQ
