3

here's the code I am using

import os
import decimal
from pyPdf import PdfFileReader
path = r"E:\python\Real Python\Real Python\Course materials\Chapter 8\Practice files"
inputFileName = os.path.join(path,"Pride and Prejudice.pdf")
inputFile = PdfFileReader(file(inputFileName,"rb"))

print "Number of pages:", inputFile.getNumPages()
print "Title:", inputFile.getDocumentInfo().title

Now, when I run this code I am getting an error:

'module' object has no attribute 'Number'

I took a screenshot of the whole output that I got when I run the above code, with errors and everything. so,please take a look and let me know what's wrong?

enter image description here

After I used import decimal in the code, I got a few errors. So, I took a screenshot of the whole thing and am attaching it here. enter image description here

faraz
  • 2,603
  • 12
  • 39
  • 61
  • Your code works fine on my system... Try `import decimal` and see if you have an error. If so, that file might be broken.. you might also post it in your question... – pradyunsg Mar 11 '13 at 10:42
  • Okay, I tried the import decimal and still getting errors. – faraz Mar 11 '13 at 11:02
  • Could you post your traceback for `import decimal` (in case you don't know, it's the text before the error... like `File blah blah...`). – pradyunsg Mar 11 '13 at 11:06
  • I just posted a screenshot of the whole thing in my original post. please take a look. – faraz Mar 11 '13 at 14:28
  • would love it if someone could help out. – faraz Mar 12 '13 at 06:08

1 Answers1

0

pyPdf is now renamed to pypdf and a couple of other classes / methods were renamed. I'm the maintainer of pypdf and PyPDF2.

Another change was that we dropped using decimal. Instead, we now use the built-in float. Hence this error will not occur in later versions of pypdf.

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958