Install & Compatibility
Where this runs
tested against v1.27.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.032s · 19.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.4s · import 0.028s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PdfFileReader
✓ from PyPDF4 import PdfFileReader
✗ import PyPDF2
from PyPDF4 import PdfFileReader
PyPDF4 is a separate fork; do not mix with PyPDF2.
Basic example: read a PDF and write its first page to a new file.
from PyPDF4 import PdfFileReader, PdfFileWriter
# Read a PDF
reader = PdfFileReader(open('example.pdf', 'rb'))
print(f"Number of pages: {reader.numPages}")
# Write a PDF
writer = PdfFileWriter()
writer.addPage(reader.getPage(0))
with open('output.pdf', 'wb') as f:
writer.write(f)
Errors
Common errors & fixes
ImportError: cannot import name 'PdfFileReader' from 'PyPDF4'
PyPDF4 is not installed or you have PyPDF2 installed instead.
fixRun: pip install pypdf4
TypeError: 'PdfFileReader' object is not callable
Using PyPDF4's PdfFileReader as a function instead of a class instantiation.
fixUse: reader = PdfFileReader(stream)
AttributeError: module 'PyPDF4' has no attribute 'PdfFileMerger'
PyPDF4 removed PdfFileMerger in favor of merging via PdfFileWriter.
fixUse PdfFileWriter and its appendPagesFromReader method.
Upgrade
Version history
1.27.0latest on PyPI · released Aug 7, 2018
Audit
Dependencies
No dependency data recorded yet.