internetarchive / archive-pdf-tools

Fast PDF generation and compression. Deals with millions of pages daily.
https://archive-pdf-tools.readthedocs.io/en/latest/
GNU Affero General Public License v3.0
86 stars 13 forks source link

First recode_pdf test: 'numpy' has no attribute 'int'. #60

Closed dwids closed 1 year ago

dwids commented 1 year ago

Just followed the install instructions, but the test recode_pdf --version gets a numpy-related error:

david@DESKTOP5:~/src/jbig2enc$ recode_pdf --version
Traceback (most recent call last):
  File "/home/david/.local/bin/recode_pdf", line 4, in <module>
    from internetarchivepdf.recode import recode
  File "/home/david/.local/lib/python3.10/site-packages/internetarchivepdf/__init__.py", line 2, in <module>
    from . import mrc
  File "/home/david/.local/lib/python3.10/site-packages/internetarchivepdf/mrc.py", line 36, in <module>
    from optimiser import optimise_gray, optimise_rgb, optimise_gray2, optimise_rgb2, fast_mask_denoise
  File "cython/optimiser.pyx", line 11, in init optimiser
  File "/home/david/.local/lib/python3.10/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Thanks.

MerlijnWajer commented 1 year ago

Thanks for the report.

You can temporarily downgrade numpy to numpy==1.23.4

Let me see if I can fix this problem for the newer numpy versions meanwhile.

MerlijnWajer commented 1 year ago

This commit ought to fix the problem: https://github.com/internetarchive/archive-pdf-tools/commit/31ebb8dad8ccae4741f21687106eb1ec89b77ed5

I'll tag a release for it this week.

dwids commented 1 year ago

Thank you, very quick work! It worked:

pip3 install numpy==1.23.4
...
recode_pdf --version
internetarchivepdf 1.5.2
jrochkind commented 1 year ago

I ran into this too, and being new to python it took me a while to figure out what was going on, and I still haven't quite managed to figure out how to use with older numpy instead, although I will eventually!

But a new release would be handy!

MerlijnWajer commented 1 year ago

I've released 1.5.3 which contains this fix, sorry it took a while.