Closed mmr-crexi closed 1 year ago
I doubt that this is a PyPDF2 issue, but people seem to stumble over this a lot: https://stackoverflow.com/q/69322531/562769
Could you please try executing
%pip install PyPDF2
In a cell of the same notebook?
Well, given that I've not encountered it in any other library, I'm pretty tempted to say it's a pypdf2 issue. Why would I need to install via apt, if this is a pure python library? Shouldn't pip be sufficient?
When I try to install in the same notebook:
!pip install PyPDF2[full]
Requirement already satisfied: PyPDF2[full] in ./venv/lib/python3.10/site-packages (2.11.2)
Requirement already satisfied: PyCryptodome in ./venv/lib/python3.10/site-packages (from PyPDF2[full]) (3.16.0)
Requirement already satisfied: Pillow in ./venv/lib/python3.10/site-packages (from PyPDF2[full]) (9.3.0)
Which is to be expected, since pip freeze
indicated that PyPDF2 was already installed.
Very weird. The capitalization should not be important, but when we move PyPDF2 back to pypdf, I'll make it all lowercase
Could there be some expectation that it be installed on the system directly? Perhaps a hardcoded path or something like that? (If that's the case, I would definitely want to know, because it would give a few extra steps to deploying to production).
Perhaps a hardcoded path or something like that?
No. The package is pretty standard from a packaging perspective
I don't have access to the collab, but I'll take your word for it :)
I'm curious as to why installing via apt would affect the solution, if I'm using a virtualenv that should also have everything in it, as per the above diagnostics.
why installing via apt would affect the solution
Why do you think it would?
However, I'd recommend never to use apt for PyPDF2. It's so much out of date
why installing via apt would affect the solution
Why do you think it would?
However, I'd recommend never to use apt for PyPDF2. It's so much out of date
I only looked at it because of this StackOverflow link:https://stackoverflow.com/q/69322531/562769, which leads to https://zoomadmin.com/HowToInstall/UbuntuPackage/python-pypdf2, which talked about installing it via apt.
I think this was a problem in my python environment.
I switched to using pyenv
and poetry
instead of using pip and my system installation, and am using 3.10.9 instead of 3.10.6 that's on my system. I can now import PyPDF2 without issues.
I am trying to import PyPDF2 into a python notebook.
Environment
Which environment were you using when you encountered the problem?
Python 3.10, with this requirements file:
using a venv created by this setup script:
Code + PDF
This is a minimal, complete example that shows the issue:
yields
My python version:
So
pip freeze
shows that the library is found and available, but not being imported, for whatever reason.My initial thinking is that the naming of the module is not compliant with PEP8:
https://peps.python.org/pep-0008/#package-and-module-names
Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.