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



S.N
  • 4,910
  • 5
  • 31
  • 51
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 ? – S.N 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 – S.N 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. – S.N 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. – S.N 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

2 Answers2

1

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

New or edit this variable and mention your path.

S.N
  • 4,910
  • 5
  • 31
  • 51
Mehak Madaan
  • 11
  • 1
  • 5
1

You can find the solution here.

pip install pdf2image

You only did the steps above.

The following step dependents on your computer system.

Windows

Windows users will have to build or download poppler for Windows. I recommend @oschwartz10612 version which is the most up-to-date. You will then have to add the bin/ folder to PATH or use poppler_path = r"C:\path\to\poppler-xx\bin" as an argument in convert_from_path.

Mac

Mac users will have to install poppler.

Installing using Brew:

brew install poppler

Linux

Most distros ship with pdftoppm and pdftocairo. If they are not installed, refer to your package manager to install poppler-utils.

Platform-independant (Using conda) Install poppler: conda install -c conda-forge poppler Install pdf2image: pip install pdf2image

Hobo Fly
  • 11
  • 2