Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPDF2 dependency error #18

Open
sjvrijn opened this issue Jan 31, 2023 · 0 comments
Open

PyPDF2 dependency error #18

sjvrijn opened this issue Jan 31, 2023 · 0 comments

Comments

@sjvrijn
Copy link

sjvrijn commented Jan 31, 2023

pdftools currently errors for me when I did a fresh install with pipx and wanted to split some files:

$ pdftools split some_file.pdf -q 12 9
Traceback (most recent call last):
  File "~/.local/bin/pdftools", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/pdftools/_cli.py", line 286, in main
    pdf_split(ARGS.src, ARGS.output, ARGS.stepsize, ARGS.sequence)
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/pdftools/pdftools.py", line 157, in pdf_split
    reader = PdfFileReader(inputfile)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/PyPDF2/_reader.py", line 1974, in __init__
    deprecation_with_replacement("PdfFileReader", "PdfReader", "3.0.0")
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/PyPDF2/_utils.py", line 369, in deprecation_with_replacement
    deprecation(DEPR_MSG_HAPPENED.format(old_name, removed_in, new_name))
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/PyPDF2/_utils.py", line 351, in deprecation
    raise DeprecationError(msg)
PyPDF2.errors.DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.

This seems related to #17, because while requirements.txt pins PyPDF2 to version 1.25.1, setup.py only lists install_requires=["PyPdf2"],

Are there any plans to update this package to the new usage?
Otherwise the simple fix would be to pin the version of PyPDF2 in setup.py,

Manually reinstalling in a fresh environment with the pinned PyPDF2 version still works:

$ pip install pdftools PyPDF2==1.25.1
Collecting pdftools
  Using cached pdftools-2.0.2-py3-none-any.whl
Collecting PyPDF2==1.25.1
  Downloading PyPDF2-1.25.1.tar.gz (194 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 194.2/194.2 kB 3.4 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Installing collected packages: PyPDF2, pdftools
  DEPRECATION: PyPDF2 is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for PyPDF2 ... done
Successfully installed PyPDF2-1.25.1 pdftools-2.0.2
$ pdftools split some_file.pdf -q 12 9 # Success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant