2

I am using python 3.7.4 on a macOS 10.14.6 and I am trying to use pdf2image to convert a pdf file into an image. So I have installed poppler with Homebrew. I get an error message when I try to convert the PDF.

Traceback (most recent call last):   File "/usr/local/lib/python3.7/site-packages/pdf2image/pdf2image.py", line 240, in _page_count
    proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE)   File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)   File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'pdfinfo': 'pdfinfo'

I use the following code:

from pdf2image import convert_from_path, convert_from_bytes
from pdf2image.exceptions import (
    PDFInfoNotInstalledError,
    PDFPageCountError,
    PDFSyntaxError
)

images = convert_from_path('test.pdf')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/michelebutturini/Desktop/Segmentation.py", line 16, in <module>
    images = convert_from_path('test.pdf')
  File "/usr/local/lib/python3.7/site-packages/pdf2image/pdf2image.py", line 54, in convert_from_path
    page_count = _page_count(pdf_path, userpw, poppler_path=poppler_path)
  File "/usr/local/lib/python3.7/site-packages/pdf2image/pdf2image.py", line 244, in _page_count
    raise PDFInfoNotInstalledError('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?
Kampi
  • 1,798
  • 18
  • 26
user216517
  • 21
  • 1
  • 2
  • 1
    `Is poppler installed and in PATH?` - do you have setup your `PATH` correctly? – Kampi Aug 21 '19 at 09:08
  • Hi Kampi, this is the PATH: /Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands and this is were poppler is: /usr/local/Cellar/poppler/0.79.0 How do I know if my PATH is correctly set up? Thanks – user216517 Aug 21 '19 at 09:57
  • try installing "poppler-utils" which is used by the poppler internally to get the count for the number of pages in the pdf. – abhishek kasana Nov 12 '20 at 08:56

3 Answers3

4

I've had this problem on Google Colab and I've fixed with this command:

!apt-get install poppler-utils
L3xpert
  • 1,109
  • 1
  • 10
  • 19
1

I had a similar issue, and found my answer here: https://github.com/Belval/pdf2image/issues/101

What SamikhaAgarwal said was:

"These pdf2image and pdftotext library backend requirement is Poppler, so you have to install

conda install -c conda-forge poppler

Then the error will be resolved, and if still it doesn't work for you, then you can follow http://blog.alivate.com.au/poppler-windows/ to install this library.

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
1

Maybe try:

brew install poppler

This worked for me.

RiveN
  • 2,595
  • 11
  • 13
  • 26
Kane Lee
  • 11
  • 1