can't use PyPDF2 to open my pdf file on jupyter notebook

753 views Asked by At

I tried opening a pdf file which I downloaded with the PyPDF2 module already installed like this:

import PyPDF2
pdfFileObj = open('ssopenpyxl-readthedocs-io-en-latest.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
pdfReader.numPages

and it gave me a filenotfound error message:

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-10-243eb92ac6df> in <module>
      1 import PyPDF2
----> 2 pdfFileObj = open('ssopenpyxl-readthedocs-io-en-latest.pdf', 'rb')
      3 pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
      4 pdfReader.numPages

FileNotFoundError: [Errno 2] No such file or directory: 'ssopenpyxl-readthedocs-io-en-latest.pdf
1

There are 1 answers

0
Atimah Adavize On

I figured it out. you need to put the file in your current working directory in other for you to open it