Open aashams10 opened 9 months ago
I have the same problem, have resolved this??
It seems that PyPDF2 (which camelot depends on) has implemented a breaking change on its API.
Short term fix is to manually install the last PyPDF2 version that works with the old API (before 3.0.0, as per the error message) after you have installed camelot:
python -m pip install "pypdf2<3"
Also, PyPDF2 is changing to PyPDF...this should be taken in account for the future. From their pypi page:
NOTE: The PyPDF2 project is going back to its roots. PyPDF2==3.0.X will be the last version of PyPDF2. Development will continue with pypdf==3.1.0.
python -m pip install "pypdf2<3". Yet error remained.
Successfully installed pypdf2-2.12.1 camelot-py 0.9.0
DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.
@juliatong , can you check with python -m pip freeze
what version of pypdf2 is installed? From your error message it seems it's still version 3.
Maybe the previous version was installed in a different virtual environment? Also, if you are using Jupyter notebooks maybe you need to quit and restart the kernel for the updated library to be loaded.
Anyway, this should not be a long term solution. Not sure if any maintainer is working on this?
@juliatong , can you check with
python -m pip freeze
what version of pypdf2 is installed? From your error message it seems it's still version 3. Maybe the previous version was installed in a different virtual environment? Also, if you are using Jupyter notebooks maybe you need to quit and restart the kernel for the updated library to be loaded. Anyway, this should not be a long term solution. Not sure if any maintainer is working on this?
Hi @paluigi, Thanks a lot to the reply. I solved the problem!
First of all, you are right. Indeed my jupter notebook wasn't picking up the change, despite Successfully installed pypdf2-2.12.1. It seems the kernel still took version 3 from the error msg you as point out. restarted the kernel, and the error msg is gone. Big shout on your attention to details.
However, after it, a new error came up. _raise RuntimeError('Ghostscript is not installed') RuntimeError: Please make sure that Ghostscript is installed .While I pip show Ghostscript is indeed there...
solution is to run commands below. _sudo apit gives error _raise RuntimeError('Ghostscript is not installed') RuntimeError: Please make sure that Ghostscript is installed .While I pip show Ghostscript is indeed there...
solution is to run commands below. sudo apt-get update sudo at-get update sudo apt-get install ghostscript
Here is the thing. The ghostscript package I installed through pip install is a Python interface to the Ghostscript C-API, and it doesn't include the Ghostscript executable itself. The Python package interacts with the Ghostscript library but doesn't install the Ghostscript command-line executable (gs). That's why above lines resolved my problem as they manually install the executable.
import PyPDF2
Function to extract and display text from a PDF
def extract_and_display_pdf(pdf_file): try:
Open the PDF file
pdf_file_path = 'sample.pdf'
extract_and_display_pdf(pdf_file_path)