SOLVED
PyPDF2 is not defined
Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
KimLamNg
8 - Asteroid
‎03-18-2023
02:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
It appears I was able to import PyPDF2 using non-admin mode. However, I got this error when the code is run. How can I fix it?
Solved! Go to Solution.
Labels:
- Labels:
- Error Message
- Python
2 REPLIES 2
apathetichell
19 - Altair
‎03-18-2023
09:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I'm not much of a Python person - but two quick things - one can you check if all of your dependencies are included (ie openpyxl - that seems to be an issue sometimes - see here: https://stackoverflow.com/questions/74475530/importerror-cannot-import-name-pdfreader-from-pypdf2)
two - if you are importing a specific method (ie "
from PyPDF2 import PdfReader
Wouldn't you refer to it just as PdfReader when using later in the code (not PyPDF2.PdfReader - since you've overtly declared your intent to use it)
from PyPDF2 import PdfReader reader = PdfReader("example.pdf") number_of_pages = len(reader.pages) page = reader.pages[0] text = page.extract_text()
‎03-18-2023
10:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Yes you’re right. I removed PyPDF2 in the later lines and the error was gone. Thank you!
