Mehak Madaan
Mehak Madaan

Reputation: 11

Poppler PDFInfoNotInstalledError

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



Upvotes: 0

Views: 11819

Answers (2)

Hobo Fly
Hobo Fly

Reputation: 11

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

Upvotes: 1

Mehak Madaan
Mehak Madaan

Reputation: 11

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

New or edit this variable and mention your path.

Upvotes: 1

Related Questions