13

I have been using camelot for our project, but since 2 days I got following errorMessage. When trying to run following code snippet:

import camelot
tables = camelot.read_pdf('C:\\Users\\user\\Downloads\\foo.pdf', pages='1')

I get this error:

DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.

I checked this file and it does use pdfFileReader: c:\ProgramData\Anaconda3\lib\site-packages\camelot\handlers.py

I thought that I can specify the version of PyPDF2, but it will be installed automatically(because the library is used by camelot) when I install camelot. Do you think there is any solution to specify the version of PyPDF2 manually?

Said Akyuz
  • 180
  • 1
  • 1
  • 11
  • 1
    In the requirements of `camelot` is specified that it needs `PyPDF2>=1.26.0`. So as long as you install a version that satisfies that requirement, everything should be fine. An [issue](https://github.com/camelot-dev/camelot/issues/339) regarding this problem already exists on their GitHub. – Clasherkasten Dec 28 '22 at 11:49
  • 1
    you can try to manually install the package: `pip install pypdf<3.0.0` – Stefano Fiorucci - anakin87 Dec 29 '22 at 09:46

5 Answers5

21

This is issues #339.

While there will hopefully be soon a release including the fix, you can still do this:

pip install 'PyPDF2<3.0'

after you've installed camelot.

See https://github.com/camelot-dev/camelot/issues/339#issuecomment-1367331630 for details and screenshots.

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
1
DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.

Just removing the file from pdfFileReader worked for me. This means writing this PdfReader instead of pdfFileReader this.

cconsta1
  • 737
  • 1
  • 6
  • 20
rishit
  • 11
  • 2
1

If anyone trying to do this on colab then run the following steps:

!pip install ghostscript
!pip install camelot-py[cv]
!pip install excalibur-py
!apt install ghostscript python3-tk

And after that check if installed:

from ctypes.util import find_library

# It will display `libgs.so.9` if installed or will print `None` if not
print(find_library("gs")) 

If still doesn't work:

!excalibur initdb

Source: here

Aayush Shah
  • 381
  • 2
  • 11
0

I just changed the imports as the error msg suggested:

# From
from PyPDF2 import PdfFileMerger
from PyPDF2 import PdfFileReader

# To
from PyPDF2 import PdfMerger
from PyPDF2 import PdfReader

In my case (version PyPDF2 3.0.0) both classes exists. And I thought that I need to change the code or something, but no, simply worked.

Ricky Levi
  • 7,298
  • 1
  • 57
  • 65
-1

I solved the issue uninstalling camelot-py and re installing it includeing the "extra cv requirement", like this:

pip install "camelot-py[base]"

I hope it can be useful!

source: https://readthedocs.org/projects/camelot-py/downloads/pdf/master/