我有一个带有nginx web应用程序的Django。我试图将PDF转换为图像。代码在本地工作,但是给了我一个
OSError at /my_function/
[Errno 2] No such file or directory
错误。
# read existing PDF
UNREDACTED_PDF = PdfFileReader(request_file.file)
WIP_PDF = PdfFileWriter()
# add page
page = UNREDACTED_PDF.getPage(0)
WIP_PDF.addPage(page)
# convert to image and back
pdf_buffer = io.BytesIO()
WIP_PDF.write(pdf_buffer)
PDFS_AS_IMAGES = StringIO()
scanned_pages = pdf2image.convert_from_bytes(pdf_buffer.getvalue(), fmt="ppm")
scanned_pages[0].save(PDFS_AS_IMAGES, "PDF",resolution=100.0)
contents = PDFS_AS_IMAGES.getvalue()
PDFS_AS_IMAGES.close()
使用Debug = True
,我在这行代码中看到了错误:
scanned_pages = pdf2image.convert_from_bytes(pdf_buffer.getvalue(), fmt="ppm")
错误陈述下降:
return convert_from_path(f.name, dpi=dpi, output_folder=output_folder, first_page=first_page, last_page=last_page, fmt=fmt, thread_count=thread_count, userpw=userpw)
page_count = __page_count(pdf_path, userpw)
proc = Popen(["pdfinfo", pdf_path], stdout=PIPE, stderr=PIPE)
Raise child_exception
OSError(2, 'No such file or directory')
我知道这是一个具体的问题。要解决这类问题的思维过程是什么?