Unable to use pypdf module

Nitin Vijay picture Nitin Vijay · Feb 9, 2017 · Viewed 45.5k times · Source

I have installed the pyPdf module successfully using the command pip install pydf but when I use the module using the import command I get the following error:

enC:\Anaconda3\lib\site-packages\pyPdf\__init__.py in <module>()
1 from pdf import PdfFileReader, PdfFileWriter
  2 __all__ = ["pdf"]
ImportError: No module named 'pdf'

What should I do? I have installed the pdf module as well but still the error does not go away.

Answer

Martin Thoma picture Martin Thoma · Oct 10, 2017

This is a problem of PyPDF, which does not occur in PyPDF2. Actually, the official pyPdf page recommends using PyPDF2.

Install PyPDF2

$ sudo -H pip install PyPDF2

You might need to replace pip by pip2 or pip3 if you use Python 2 or Python 3.

Use PyPDF2

import PyPDF2

Moving from pyPdf to PyPDF2

Simply replace all occurrences of pyPdf by PyPDF2.

WARNING: PyPDF, PyPDF2, PyPDF3, PyPDF4 are all not maintained!

Three potential alternatives which are maintained: