abarker / pdfCropMargins

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

How to deal with this new error? #29

Closed NamelessUzer closed 2 years ago

NamelessUzer commented 4 years ago
> pdf-crop-margins.exe -p 0 -o o.pdf 1.df -v
 ** On entry to DGEBAL parameter number  3 had an illegal value
 ** On entry to DGEHRD  parameter number  2 had an illegal value
 ** On entry to DORGHR DORGQR parameter number  2 had an illegal value
 ** On entry to DHSEQR parameter number  4 had an illegal value

Caught an unexpected exception in the pdfCropMargins program.
Unexpected error:  <class 'RuntimeError'>
Error message   :  The current Numpy installation ('c:\\python\\lib\\site-packages\\numpy\\__init__.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86

  File "c:\python\lib\site-packages\pdfCropMargins\pdfCropMargins.py", line 48, in main
    from .main_pdfCropMargins import main_crop
  File "c:\python\lib\site-packages\pdfCropMargins\main_pdfCropMargins.py", line 78, in <module>
    from .calculate_bounding_boxes import get_bounding_box_list
  File "c:\python\lib\site-packages\pdfCropMargins\calculate_bounding_boxes.py", line 45, in <module>
    from PIL import Image, ImageFilter, __version__ as pillow_version
  File "c:\python\lib\site-packages\PIL\ImageFilter.py", line 20, in <module>
    import numpy
  File "c:\python\lib\site-packages\numpy\__init__.py", line 305, in <module>
    _win_os_check()
  File "c:\python\lib\site-packages\numpy\__init__.py", line 302, in _win_os_check
    raise RuntimeError(msg.format(__file__)) from None
abarker commented 4 years ago

That's a Windows/Numpy bug that recently got introduced. The Windows developers are apparently promising a fix in January. The link in the error message describes the problem.

The pdfCropMargins program doesn't even require Numpy, so one workaround would be to simply use pip to uninstall Numpy. (The pdfCropMargins program uses Pillow, which simply tries to import Numpy to see if it is available. But Numpy is throwing a RuntimeError instead of the ImportError that the Pillow code looks for.)

If you need both Numpy and pdfCropMargins installed, another possible workaround to try (discussed here: https://stackoverflow.com/questions/64654805/how-do-you-fix-runtimeerror-package-fails-to-pass-a-sanity-check-for-numpy-an) is to revert the numpy version:

pip install numpy==1.19.3