abarker / pdfCropMargins

pdfCropMargins -- a program to crop the margins of PDF files
Other
361 stars 35 forks source link

Error in pdfCropMargins: No system PyPDF2 Python package was found #36

Closed sulunemre closed 2 years ago

sulunemre commented 2 years ago

pypdf2 package is not found though it is installed.

Install output:

> pip install pypdf2 pdfCropMargins --upgrade
Requirement already satisfied: pypdf2 in ....... (1.27.6)
Requirement already satisfied: pdfCropMargins in ....... (1.0.5)
Requirement already satisfied: wheel in ....... (from pdfCropMargins) (0.37.1)
Requirement already satisfied: pillow>=7.1.0 in ....... (from pdfCropMargins) (9.1.0)

Run output:

> pdf-crop-margins.exe .\test.pdf

Error in pdfCropMargins: No system PyPDF2 Python package
was found.  Reinstall pdfCropMargins via pip or install that
dependency ('pip install pypdf2').
abarker commented 2 years ago

I haven't tested the program with Windows 11 since I still run Windows 10. On Linux it still works for me with pypdf2 1.27.7 (the latest version). They have started development back again, though, so it could be a bug in the 1.27.6 distribution. Try upgrading pypdf2, or maybe regressing it to something like 1.26.0 if that doesn't work.

If that still doesn't work, open a Python shell instance and type import PyPDF2 and see if your system is correctly set up to do the imports.

sulunemre commented 2 years ago

I tried the exact same steps today and it works 😄 I think it was because of this bug in pypdf2 and it's fixed in a recent release yesterday (version 1.27.7)

StevenClontz commented 2 years ago

I believe this needs to be reopened as the same breaking change was implemented in pydf2's 2.0 release. Either https://github.com/abarker/pdfCropMargins/blob/master/src/pdfCropMargins/main_pdfCropMargins.py#L71 should be importing from PyPDF2.errors and require a 2.x release of PyPDF2, or this package should require a 1.x release.

abarker commented 2 years ago

I pushed a bug fix out (1.0.6) which tries the errors module and then the utils module if that fails.

StevenClontz commented 2 years ago

This fixed things for us downstream, thanks.