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)
-
Name the folder that holds pdfinfo. On a Mac or Linux,
which pdfinfoprints it. -
poppler_pathwins over the PATH, so a wrong one fails. -
Windows trap: pdf2image's README says
poppler-xx\bin. The 26.09.0 zip has onlypoppler-26.09.0\Library\bin. Pass that, as a raw string:r"C:\...\Library\bin".
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
- Poppler not on the PATH
-
poppler_pathset to a folder that does not exist poppler_pathset to the folder above binpoppler_pathset to the pdfinfo filepoppler_pathwrong, with Poppler on the PATH- A folder with pdftoppm and no pdfinfo
- pdfinfo with no run permission
Different ending? Check the PDF first
| 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']
| 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
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
- Its table code was tuned on half of those invoices. On the other half: 1,594 of 1,598.
- The 24 stock lists have no totals to check against: 98.6%.
- Digital pages use the PDF's own text. Files upload to your Apify run, and go to no LLM or other API.
- $0.006 a page, scanned or digital, plus $0.00005 a run at the default 1 GB.
- The Apify free plan lets you try 20 pages a run and 50 a month.
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
- pdf2image 1.17.0 (MIT), PyMuPDF 2.0, pypdfium2 5.14.0, Tesseract 5.5.3.
- Poppler (GPL): 26.03.0 on the Mac, 25.03.0 on Debian 13.
- pdf2image README
- poppler-windows 26.09.0-0
- pypdfium2 5.14.0 on PyPI
- We make the Apify Actor. The other tools are open source, and we do not make them.