0

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?```



Sreejith Nair
  • 4,640
  • 5
  • 28
  • 44
Mehak Madaan
  • 11
  • 1
  • 5
  • This is very much context specific error. Where does this testing_ocrpdf.py located ? can you post complete code? Can you also check whether you installed poppler-utils ? – Sreejith Nair Nov 13 '19 at 08:58
  • now i've placed the code in documents folder and mentioned the complete code above & tried installing poppler-utils but got this error: – Mehak Madaan Nov 13 '19 at 09:27
  • C:\Users\mehak\Documents>pip install poppler-utils ERROR: Could not find a version that satisfies the requirement poppler-utils (from versions: none) ERROR: No matching distribution found for poppler-utils – Mehak Madaan Nov 13 '19 at 09:27
  • To use poppler, you need to have poppler-utils installed on your machine and in your path. https://github.com/Belval/pdf2image/blob/master/README.md – Sreejith Nair Nov 13 '19 at 09:34
  • i've installed "poppler-0.51" and added the same as poppler_path in env var as : "C:\Program Files\poppler-0.51_x86\poppler-0.51\bin" but getting the same errors – Mehak Madaan Nov 13 '19 at 09:42
  • can you add complete source and the files. – Sreejith Nair Nov 13 '19 at 10:09
  • it's done now, i added its path as "new" in "Path" already mentioned in env var, then it worked fine. No need to create new path in system variables. – Mehak Madaan Nov 19 '19 at 05:18
  • That's great. Good to know. You can mark your thread as answer. So others find it helpful. – Sreejith Nair Nov 19 '19 at 09:24
  • Does this answer your question? [Poppler in path for pdf2image](https://stackoverflow.com/questions/53481088/poppler-in-path-for-pdf2image) – Grant Curell Mar 24 '21 at 14:56

1 Answers1

1

I followed these steps to include path and it works as expected.

New or edit this variable and mention your path.

Sreejith Nair
  • 4,640
  • 5
  • 28
  • 44
Mehak Madaan
  • 11
  • 1
  • 5