Home > Mobile >  pdf file path not found
pdf file path not found

Time:02-04

(I am using Windows 10, PyCharm)

I am running the following script in the console:

pdfFileObj = open(samplepdf.pdf, 'rb')

This is the result:

NameError: name 'samplepdf' is not defined

I checked and made sure that the pdf file is within the project folder that I am operating out of on PyCharm.

I also tried running the same script with the direct path to the file:

pdfFileObj = open(C:\Users\Rolex\PycharmProjects\pdf\samplepdf.pdf, 'rb')

and received the same result:

NameError: name 'samplepdf' is not defined

CodePudding user response:

Surround you filename with quotation marks

pdfFileObj = open('samplepdf.pdf', 'rb')

Whenever you get a '<> not defined', it means that python is treating <> as a variable. In this case, you do not have a variable called samplepdf. The error messages should help you diagnose your issues.

  • Related