Cannot Remove File: Device or resource busy

Christian Heimes lists at cheimes.de
Wed Nov 17 08:17:24 EST 2010


Am 17.11.2010 09:16, schrieb Brett Bowman:
> Good ideas, but I've tried them already:
> -No del command, or replacing it with a set-to-null, neither solve my file
> access problem.
> -PdfFileReader has no close() function, and causes an error.  Weird, but
> true.
> -pdf_handle.close() on the other hand, fails to solve the problem.

You have to close the file explicitly, for example with a proper with block.

with open(outputFile, "rb") as fh:
    pdf_pypdf = PdfFileReader(fh)
    # process the PDF file here

Christian




More information about the Python-list mailing list