Part of PDF rendering and conversion using Poppler
, I have following code in place but executing code ended-up having error which is mentioned below.
Error message: pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
I have added the Poppler path as environment variable but error still persist.
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?```
I followed these steps to include path and it works as expected.