Tools,

Unable to get page count: the pdf2image Poppler fix

7 setups

I tested with Poppler installed gave this error

Try it on your PDF, $0.006 a page

Install it, or name its folder

System Do this
Mac brew install poppler
Debian apt-get update && apt-get install -y poppler-utils
Windows Unzip a poppler-windows release. Not run here
pip No fix. pip install poppler finds no package, and poppler-utils added no pdfinfo on Debian
from pdf2image import convert_from_path

pages = convert_from_path(
    "scan.pdf",
    dpi=300,
    poppler_path="/opt/homebrew/bin",
)
print(len(pages), pages[0].size)
1 (2550, 3300)

Ask Python what it can see

All 7 setups below had one cause: Python could not start pdfinfo. No Poppler at all gives the same message. Run this where the error happens:

import shutil

for tool in ("pdfinfo", "pdftoppm"):
    print(tool, shutil.which(tool))
pdfinfo None
pdftoppm None

None: Poppler is not on this PATH. A path, and still the error: check your poppler_path.

The 7 setups that gave the error
  1. Poppler not on the PATH
  2. poppler_path set to a folder that does not exist
  3. poppler_path set to the folder above bin
  4. poppler_path set to the pdfinfo file
  5. poppler_path wrong, with Poppler on the PATH
  6. A folder with pdftoppm and no pdfinfo
  7. pdfinfo with no run permission

Different ending? Check the PDF first

After "Unable to get page count."
You see Cause and fix
Couldn't open file Wrong path to the PDF
Document stream is empty A 0-byte file. Get it again
May not be a PDF file Not a PDF, for example a saved web page
Couldn't find trailer dictionary A cut-off PDF. Get it again
Incorrect password Pass userpw="..."
error while loading shared libraries Broken install. Reinstall Poppler

These are PDFPageCountError. "Is poppler installed" is PDFInfoNotInstalledError.

Or drop Poppler: pypdfium2 needs only pip

import pypdfium2
import pytesseract

for page in pypdfium2.PdfDocument("scan.pdf"):
    image = page.render(scale=300 / 72).to_pil()
    text = pytesseract.image_to_string(
        image, config="--dpi 300"
    )
    print(image.size, text.split()[:4])
(2550, 3301) ['Northfield', 'Supply', '-', 'Invoice']
Tesseract right, same scans at 300 dpi
Draws the page 72 made-up invoices 55 book pages
pdf2image 87.7% 94.4%
PyMuPDF 89.1% 94.3%
pypdfium2 86.9% 94.3%

No renderer won on both sets. Pick on license: pypdfium2 is BSD and Apache, and PyMuPDF is AGPL or paid. You still need Tesseract: its own error is here.

All 100 pages at once held 8.9 GB

Peak Python memory, 100 scanned pages at 300 dpi
pdf2image, all pages at once
8,872 MB
All at once, thread_count=4
7,604 MB
PyMuPDF
784 MB
pypdfium2
233 MB
pdf2image, one page at a time
162 MB
output_folder, paths_only
58 MB
from pdf2image import convert_from_path, pdfinfo_from_path

count = pdfinfo_from_path("hundred.pdf")["Pages"]
for n in range(1, count + 1):
    image = convert_from_path(
        "hundred.pdf", dpi=300, first_page=n, last_page=n
    )[0]
    # OCR image here.
print(count, image.size)

12.4 s one page at a time

8.7 s all pages at once

Poppler's own process adds about 70 MB to each pdf2image row, so one page at a time ties pypdfium2, which took 3.3 s.

output_folder wrote 2,525 MB of PPM files to disk.

No install at all: try our Actor

PDF OCR to Markdown, our Apify Actor, needs no Poppler or Tesseract on your machine.

99.6% of numbers right, 72 made-up invoices

94.3% of book words right, no better than plain Tesseract

Questions people ask

Why does my terminal find Poppler and my script not?

A script from cron or launchd can get a shorter PATH. With only /usr/bin and /bin on the PATH, Homebrew's Poppler gave the error. Set PATH in that job, or pass poppler_path.

Does convert_from_bytes need Poppler too?

Yes. It gave the same error with Poppler off the PATH.

Do I need both pdfinfo and pdftoppm?

Yes. With no pdftoppm, the error was FileNotFoundError, and it named pdftoppm.

How do I fix it in Docker?

The python:3.13-slim image has no Poppler. Inside it, the Debian command above fixed the error.

Method, limits and sources

How I tested it

Errors: one test PDF and its broken copies, on a Mac and in a Debian container. The PATH was set for each run. I made these setups on purpose, so they are examples, not a survey.

Memory: 100 scanned Letter pages at dpi=300, each loaded as a Pillow image in a fresh process, with no OCR. pdf2image's own default is 200 dpi, which I did not run. Memory is the highest of 3 runs, and time is the median.

OCR: the invoice and Wikisource book scans of our PyMuPDF guide. Tesseract ran with --dpi 300 and the default model. Invoices count the numbers right, and books count the true words found in order.

The Actor is build 0.1.32's own page code, run on this Mac. Scripts and results are in research/bench/pdf2image-poppler-2026-11-02/.

What I did not test
  • Windows. I only listed the files in the zip.
  • conda-forge Poppler.
  • Memory on Linux.
Versions and sources