2

I installed the PyPDF2 package using pip and got the following message after the installation:

!pip install PyPDF2
Collecting PyPDF2
  Downloading PyPDF2-2.11.1-py3-none-any.whl (220 kB)
     -------------------------------------- 220.4/220.4 kB 2.7 MB/s eta 0:00:00
Requirement already satisfied: typing-extensions>=3.10.0.0 in c:\users\dell\appdata\local\programs\python\python37\lib\site-packages (from PyPDF2) (3.10.0.2)
Installing collected packages: PyPDF2
Successfully installed PyPDF2-2.11.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
camelot-py 0.10.1 requires openpyxl>=2.5.8, which is not installed.

I imported PdfReader and ran the following code:

from PyPDF2 import PdfReader

reader = PdfReader(r"D:\Sample.pdf")
for page in reader.pages:
    for image in page.images:
        with open(image.name, "wb") as fp:
            fp.write(image.data)

But, I get an "ImportError":

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_19816/3180674727.py in <module>
----> 1 from PyPDF2 import PdfReader
      2 
      3 reader = PdfReader(r"D:\Sample.pdf")
      4 for page in reader.pages:
      5     for image in page.images:

ImportError: cannot import name 'PdfReader' from 'PyPDF2' (C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\PyPDF2\__init__.py)

Any inputs on how to resolve this issue?

  • 1
    "camelot-py 0.10.1 requires openpyxl>=2.5.8" do you have openpyxl>=2.5.8 installed? – Sembei Norimaki Nov 17 '22 at 12:47
  • Thanks, this helped. I installed the latest version of openpyxl (3.0.10) and it worked! – Surya Teja Chavali Nov 17 '22 at 12:57
  • 1
    I'm confused. Is the question about PyPDF2 or openpyxl? Is it solved? If yes, please post an answer – Martin Thoma Nov 19 '22 at 20:59
  • The question was about PyPDF2. I installed the package using 'pip', but then I wasn't able to import the PdfReader module from it. During the installation as you can see, I overlooked an error it threw, saying that "pip's dependency resolver does not currently take into account all the packages that are installed". Then when @SembeiNorimaki pointed out that I have to install openpyxl>=2.5.8, I looked upon the error and resolved its dependency conflict with PyPDF2 by installing the latest version of openpyxl. – Surya Teja Chavali Nov 20 '22 at 06:32
  • @SuryaTejaChavali Could you make your comment please an answer? – Martin Thoma Feb 28 '23 at 20:54

1 Answers1

1

The question was about PyPDF2. I installed the package using 'pip', but then I wasn't able to import the PdfReader module from it. During the installation as you can see, I overlooked an error it threw, saying that "pip's dependency resolver does not currently take into account all the packages that are installed". Then when @SembeiNorimaki, in the above comments, pointed out that I have to install openpyxl>=2.5.8. I looked upon the error and resolved its dependency conflict with PyPDF2 by installing the latest version of openpyxl. –