波普勒 PDFInfoNotInstalledError

Poppler PDFInfoNotInstalledError

部分 PDF 渲染和转换使用 Poppler,我有以下代码,但执行代码最终出现错误,如下所述。

Error message: pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?

我已将 Poppler 路径添加为环境变量,但错误仍然存​​在。

import tempfile,os
with tempfile.TemporaryDirectory() as path:
    images_from_path = convert_from_path("C:\Users\mehak\OneDrive\Desktop\iffco.pdf")

index = 1
for image in images_from_path:
    image.save("C:\Users\mehak\OneDrive\Desktop" + str(index) + ".jpg")
    index += 1```



```Traceback (most recent call last):
  File "C:\Users\mehak\AppData\Local\Programs\Python\Python37\lib\site-packages\pdf2image\pdf2image.py", line 355, in _page_count
    proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE)
  File "C:\Users\mehak\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "C:\Users\mehak\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "testing_ocrpdf.py", line 7, in <module>
    images_from_path = convert_from_path('D:\iffco.pdf')
  File "C:\Users\mehak\AppData\Local\Programs\Python\Python37\lib\site-packages\pdf2image\pdf2image.py", line 82, in convert_from_path
    page_count = _page_count(pdf_path, userpw, poppler_path=poppler_path)
  File "C:\Users\mehak\AppData\Local\Programs\Python\Python37\lib\site-packages\pdf2image\pdf2image.py", line 360, in _page_count
    "Unable to get page count. Is poppler installed and in PATH?"
pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?```



我按照这些步骤添加了路径,它按预期工作。

New or edit this variable and mention your path.