ocrmypdf / OCRmyPDF

OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched
http://ocrmypdf.readthedocs.io/
Mozilla Public License 2.0
14.12k stars 1.02k forks source link

[Bug]: "AttributeError: module 'numpy.typing' has no attribute 'NDArray'" after Homebrew installation #1387

Closed tillboehringer closed 2 months ago

tillboehringer commented 2 months ago

What were you trying to do?

Just straight up convert a File with: ocrmypdf Statistics_raw.pdf Statistics.pdf or even get the version with: ocrmypdf --version

But I get: AttributeError: module 'numpy.typing' has no attribute 'NDArray'

Where are you installing/running from?

Homebrew

OCRmyPDF version

can't output version, installed 28.08.24

What operating system are you working on?

macOS

Operating system details and version

14.6.1

Simple sanity checks

Relevant log output

% ocrmypdf --version
Traceback (most recent call last):
  File "/opt/homebrew/bin/ocrmypdf", line 5, in <module>
    from ocrmypdf.__main__ import run
  File "/opt/homebrew/Cellar/ocrmypdf/16.4.3/libexec/lib/python3.12/site-packages/ocrmypdf/__init__.py", line 10, in <module>
    from ocrmypdf import helpers, hocrtransform, pdfa, pdfinfo
  File "/opt/homebrew/Cellar/ocrmypdf/16.4.3/libexec/lib/python3.12/site-packages/ocrmypdf/helpers.py", line 26, in <module>
    import img2pdf
  File "/opt/homebrew/Cellar/ocrmypdf/16.4.3/libexec/lib/python3.12/site-packages/img2pdf.py", line 25, in <module>
    from PIL import Image, TiffImagePlugin, GifImagePlugin, ImageCms
  File "/opt/homebrew/opt/pillow/lib/python3.12/site-packages/PIL/Image.py", line 68, in <module>
    from ._typing import StrOrBytesPath, TypeGuard
  File "/opt/homebrew/opt/pillow/lib/python3.12/site-packages/PIL/_typing.py", line 10, in <module>
    NumpyArray = npt.NDArray[Any]
                 ^^^^^^^^^^^
AttributeError: module 'numpy.typing' has no attribute 'NDArray'
jbarlow83 commented 2 months ago

Not my circus, not my monkeys, I'm afraid. This is an issue in Pillow, or Homebrew. Or numpy.

tillboehringer commented 2 months ago

Not my circus, not my monkeys, I'm afraid. This is an issue in Pillow, or Homebrew. Or numpy.

Ok then I will look into this, but thanks for the fast reply and the time you invest into the project.

onjour commented 2 months ago

I'm having the same issue as well on my MBP M1 running on Sonoma. I'm really not tech savvy and I'm clueless on how to troubleshoot this. If someone can help that'd be much appreciated!

onjour commented 2 months ago

@tillboehringer in the meantime I bashed my daily command

...and ocrmypdf is working again, I don't understand what happened but I'm relieved!

jbarlow83 commented 2 months ago

@onjour That suggests it was temporary breakage that probably broke a lot of other things, and Homebrew has since fixed it all.

tillboehringer commented 2 months ago

@tillboehringer in the meantime I bashed my daily command

  • brew update && brew upgrade && brew cleanup

...and ocrmypdf is working again, I don't understand what happened but I'm relieved!

Sadly didn't work for me, but when I have some more time I will try to troubleshoot the matter. Thank you all for the tips.