I tried to install PyPDF2 via pip using python 3.6 on MacOS with the command:
pip3 install PyPDF2
Unfortunately when trying to import PyPDF2, it get a ModuleNotFoundError.
Through my search, I also stumbled over some dependency to pdfmerge, but installing it just threw another error. Regarding to other people who had the same problem, setuptools has to be updated.
But running
pip3 install --upgrade setuptools
did not help. I hope this is the right place to report/ask for help.
Thanks!
~/Projects/test_pypdf2$ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyPDF2
>>> dir(PyPDF2)
['PageRange', 'PdfFileMerger', 'PdfFileReader', 'PdfFileWriter', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_version', 'filters', 'generic', 'merger', 'pagerange', 'parse_filename_page_ranges', 'pdf', 'utils']
>>> PyPDF2.PdfFileMerger
<class 'PyPDF2.merger.PdfFileMerger'>
Not a "proper" fix for your problem, but you can clone the PyPDF2 github repo into your working directory for whichever python script you're working on, then do an import.
Project Directory:
yourScript.py
PyPDF2
In yourScript.py:
import PyPDF2.pdf
from PyPDF2.pdf import PdfFileReader
If you have things organized like this, it should work perfectly.
is-bug
From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF
label
Apr 7, 2022
This allows the project to make use of modern Python packaging features such as wheels, isolated builds, and more.
The change is also going to be necessary soon; distutils will soon be deprecated in 3.10, and removed from the standard library in 3.12.
Closes #465
Closes #313
Might fix #581 , #456
pypdf is available on pypi.org so you should not meet an issue to install it if your python/network configuration is correct. as an alternative you should download manually the whl file from https://pypi.org/project/pypdf/#files and then pass the whl file as argument :
pip install file.whl