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
104 stars 14 forks source link

error during installation #70

Open zbgns opened 1 month ago

zbgns commented 1 month ago

I have tried to install the program using pipx on Debian Testing with command pipx install archive-pdf-tools. There is an error that prevents the installation, and Python outputs the following log

PIP STDOUT
----------
Collecting archive-pdf-tools
  Using cached archive-pdf-tools-1.5.4.tar.gz (194 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'

PIP STDERR
----------
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "/home/zbgns_debian/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/zbgns_debian/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/zbgns_debian/.local/share/pipx/shared/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-yrt108ie/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-yrt108ie/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 303, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-yrt108ie/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 521, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-yrt108ie/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 319, in run_setup
          exec(code, locals())
        File "<string>", line 2, in <module>
      ImportError: cannot import name 'convert_path' from 'setuptools' (/tmp/pip-build-env-yrt108ie/overlay/lib/python3.12/site-packages/setuptools/__init__.py)
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

BTW I have the same on Manjaro. I also tried installing it directly by pip3 with --break-system-packages flag and the error output is pretty much the same on both systems. On the other hand I was able to install it on Ubuntu 24.04 about a year ago and it still works.

MerlijnWajer commented 4 weeks ago

Thanks for the report, I will look into this in the next few days.

MerlijnWajer commented 4 weeks ago

Oh... I did remember this from somewhere. I do have the fixes in the 1.4.x branch for this it looks like:

commit e5804a5b76e666c3905ab4e36071bce0012caac5
Author: Merlijn Wajer <merlijn@wizzup.org>
Date:   Wed Jun 26 23:56:28 2024 +0200

    setup.py: stop using convert_path

    This is now deprecated in setuptools

maybe I did not backport the fixes to the 1.5.x master branch - internally we still rely on 1.4.x.

zbgns commented 4 weeks ago

Thank you for the reply. In the meantime I switched to Debian stable. When I install by pipx install archive-pdf-tools it apparently goes successfully

  installed package archive-pdf-tools 1.5.4, installed using Python 3.11.2
  These apps are now globally available
    - compress-pdf-images
    - epub-to-pdf
    - pdf-metadata-json
    - pdfcomp
    - recode_pdf

but after recode_pdf --version I have the following

Traceback (most recent call last):
  File "/home/zbgns/.local/bin/recode_pdf", line 4, in <module>
    from internetarchivepdf.recode import recode
  File "/home/zbgns/.local/pipx/venvs/archive-pdf-tools/lib/python3.11/site-packages/internetarchivepdf/__init__.py", line 2, in <module>
    from . import mrc
  File "/home/zbgns/.local/pipx/venvs/archive-pdf-tools/lib/python3.11/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 1, in init optimiser
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

I followed your instruction and tried to downgrade version (after uninstalling the current one) pipx install archive-pdf-tools==1.4.14 but the instllation is terminated with the following error message

 Fatal error from pip prevented installation. Full pip output in file:
    /home/zbgns/.local/pipx/logs/cmd_2024-11-02_11.13.59_pip_errors.log

pip seemed to fail to build package:
    archive-pdf-tools==1.4.14

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    ImportError: cannot import name 'convert_path' from 'setuptools' (/tmp/pip-build-env-wjjk45_t/overlay/lib/python3.11/site-packages/setuptools/__init__.py)

Error installing archive-pdf-tools from spec 'archive-pdf-tools==1.4.14'.

I tried to downgrade it to even earlier version pipx install archive-pdf-tools==1.4.10 and there is still fatal error during installation, although the error message is a bit different

Fatal error from pip prevented installation. Full pip output in file:
    /home/zbgns/.local/pipx/logs/cmd_2024-11-02_13.06.42_pip_errors.log

pip seemed to fail to build package:
    archive-pdf-tools==1.4.10

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    AttributeError: 'NoneType' object has no attribute 'is_builtin_type'
    Cython.Compiler.Errors.CompileError: cython/optimiser.pyx

Error installing archive-pdf-tools from spec 'archive-pdf-tools==1.4.10'.
MerlijnWajer commented 4 weeks ago

Could you try archive-pdf-tools==1.4.29 ?

zbgns commented 4 weeks ago

It installs, but unfortunately crashes when i try to run recode_pdf --version


A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/home/zbgns/.local/bin/recode_pdf", line 4, in <module>
    from internetarchivepdf.recode import recode
  File "/home/zbgns/.local/pipx/venvs/archive-pdf-tools/lib/python3.11/site-packages/internetarchivepdf/__init__.py", line 2, in <module>
    from . import mrc
  File "/home/zbgns/.local/pipx/venvs/archive-pdf-tools/lib/python3.11/site-packages/internetarchivepdf/mrc.py", line 36, in <module>
    from optimiser import optimise_gray, optimise_rgb, optimise_gray2, optimise_rgb2, fast_mask_denoise
Traceback (most recent call last):
  File "/home/zbgns/.local/bin/recode_pdf", line 4, in <module>
    from internetarchivepdf.recode import recode
  File "/home/zbgns/.local/pipx/venvs/archive-pdf-tools/lib/python3.11/site-packages/internetarchivepdf/__init__.py", line 2, in <module>
    from . import mrc
  File "/home/zbgns/.local/pipx/venvs/archive-pdf-tools/lib/python3.11/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 1, in init optimiser
ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it).
MerlijnWajer commented 4 weeks ago

Thank you for trying. I will take a look at this, but probably after the weekend. I think you could try to build the package yourself and this error will go away. If you get the source tar for it (or just the latest 1.4.x branch), and then run python setup.py bdist_wheel. You can also try to set up a virtual env and ensure the numpy version isn't 2.x.

zbgns commented 4 weeks ago

Thanks, I'm really grateful. I will try to build it later on, although my knowledge on is very limited.