尝试在MAC上将多页PDF转换为单个.png文件时出现路径错误

2024-09-21 00:50:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将一个多页的.pdf文件转换为几个单独的.png文件。我正在使用pdf2Image来完成这项工作。我已使用brew安装poppler安装了poppler。我不确定如何在shell中查找并显式写入路径。这是我的代码:

from pdf2image import convert_from_path

from pdf2image.exceptions import (
 PDFInfoNotInstalledError,
 PDFPageCountError,
 PDFSyntaxError
)

images = convert_from_path('Bliss.pdf')

for i, image in enumerate(images):
    fname = 'Bliss'+str(i)+'.png'
    image.save(fname, "PNG")
    

这就是我得到的错误:


  File "/opt/anaconda3/lib/python3.7/site-packages/pdf2image/pdf2image.py", line 468, in pdfinfo_from_path
    "Unable to get page count. Is poppler installed and in PATH?"

PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?

有什么想法吗?提前谢谢


Tags: 文件pathinfromimageimportconvertpdf

热门问题