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

ModuleNotFoundError issue with PyPDF2==2.10.1 #1242

Closed
JaMe76 opened this issue Aug 15, 2022 · 4 comments
Closed

ModuleNotFoundError issue with PyPDF2==2.10.1 #1242

JaMe76 opened this issue Aug 15, 2022 · 4 comments

Comments

@JaMe76
Copy link

JaMe76 commented Aug 15, 2022

When importing

from PyPDF2 import PdfFileReader, PdfFileWriter

I get an immediate error

Traceback (most recent call last):
  File "~/dummy.py", line 21, in <module>
    from PyPDF2 import PdfFileReader, PdfFileWriter
  File "~/venv/lib/python3.8/site-packages/PyPDF2/__init__.py", line 10, in <module>
    from ._encryption import PasswordType
  File "~/venv/lib/python3.8/site-packages/PyPDF2/_encryption.py", line 36, in <module>
    from PyPDF2.generic import (
ModuleNotFoundError: No module named 'PyPDF2.generic'

This occurs with the latest

pip install PyPDF2==2.10.1

The older version works as expected:

pip install PyPDF2==2.10.0

Environment

Which environment were you using when you encountered the problem?

$ python -m platform
Linux-5.15.0-46-generic-x86_64-with-glibc2.29

$ python -c "import PyPDF2;print(PyPDF2.__version__)"
File "<string>", line 1, in <module>
  File "~/venv/lib/python3.8/site-packages/PyPDF2/__init__.py", line 10, in <module>
    from ._encryption import PasswordType
  File "~/venv/lib/python3.8/site-packages/PyPDF2/_encryption.py", line 36, in <module>
    from PyPDF2.generic import (
ModuleNotFoundError: No module named 'PyPDF2.generic'

Code + PDF

from PyPDF2 import PdfFileReader, PdfFileWriter

Share here the PDF file(s) that cause the issue. The smaller they are, the
better. Let us know if we may add them to our tests! -> No PDF required

Traceback

This is the complete Traceback I see:

 File "<string>", line 1, in <module>
 File "~/venv/lib/python3.8/site-packages/PyPDF2/__init__.py", line 10, in <module>
 from ._encryption import PasswordType
 File "~/venv/lib/python3.8/site-packages/PyPDF2/_encryption.py", line 36, in <module>
 from PyPDF2.generic import (
ModuleNotFoundError: No module named 'PyPDF2.generic'
@ezarowny
Copy link

I'm also seeing this same error on Python 3.10 with the same imports.

@WCM-KJD-II
Copy link

WCM-KJD-II commented Aug 15, 2022

I see the same error with python 3.8. The package is missing the generic.py file in 2.10.1, present in 2.10.0

@MartinThoma
Copy link
Member

Duplicate of #1241

I'm sorry for the hickup; I forgot to add the submodule to the distribution. It's fixed with PyPDF2==2.10.2

@MartinThoma
Copy link
Member

@JaMe76 Thank you for reporting the issue so quickly ❤️

If you want to, I would add you as a contributor: https://pypdf2.readthedocs.io/en/latest/meta/CONTRIBUTORS.html

MartinThoma pushed a commit that referenced this issue Aug 17, 2022
PR modifies the package CI job in two ways:

1. Pass package to check-wheel-contents. This makes it so that check-wheel-contents verifies that each file in the package are actually in the wheel following their directory structure.
2. Have CI steps that verify we can install the package, and that we can run a minimal example with it 

Either of these steps would have been sufficient to have caught #1242 per the example runs above.

Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
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

4 participants