Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to use pypdf module

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.

like image 584
Nitin Vijay Avatar asked Feb 09 '17 07:02

Nitin Vijay


People also ask

Does PyPDF2 work with Python 3?

Use PyPDF2. I've been using it in Python 3 (v3. 5.2 to be precise), and it works quite well. Here's a simple command that you can use to install PyPDF2.


1 Answers

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:

  • pymupdf: uses mupdf
  • pikepdf: Uses qpdf
  • pdfminer.six: A pure Python project. Don't confuse it with the unmaintained pdfminer
like image 174
Martin Thoma Avatar answered Sep 18 '22 16:09

Martin Thoma