In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

PyPDF2 is not defined

KimLamNg
8 - Asteroid

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?

KimLamNg_0-1679175289860.png

 

2 REPLIES 2
apathetichell
19 - Altair

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()
KimLamNg
8 - Asteroid

Yes you’re right. I removed PyPDF2 in the later lines and the error was gone. Thank you!

Labels
Top Solution Authors