Belval / pdf2image

A python module that wraps the pdftoppm utility to convert PDF to PIL Image object
MIT License
1.6k stars 194 forks source link

FileNotFoundError with poppler_path #280

Open HannaHUp opened 8 months ago

HannaHUp commented 8 months ago

I have installed Poppler Release-23.11.0-0 and here is my code

!pip install pdf2image
!pip install poppler-utils

pdf_path = "/home/compressed.pdf"
images = convert_from_path(pdf_path,
                           poppler_path="/home/Release-23.11.0-0/poppler-23.11.0/Library/bin")

I still got this FileNotFoundError

FileNotFoundError Traceback (most recent call last) File /opt/conda/lib/python3.10/site-packages/pdf2image/pdf2image.py:581, in pdfinfo_from_path(pdf_path, userpw, ownerpw, poppler_path, rawdates, timeout, first_page, last_page) 580 env["LD_LIBRARY_PATH"] = poppler_path + ":" + env.get("LD_LIBRARY_PATH", "") --> 581 proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE) 583 try:

File /opt/conda/lib/python3.10/subprocess.py:971, in Popen.init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize) 968 self.stderr = io.TextIOWrapper(self.stderr, 969 encoding=encoding, errors=errors) --> 971 self._execute_child(args, executable, preexec_fn, close_fds, 972 pass_fds, cwd, env, 973 startupinfo, creationflags, shell, 974 p2cread, p2cwrite, 975 c2pread, c2pwrite, 976 errread, errwrite, 977 restore_signals, 978 gid, gids, uid, umask, 979 start_new_session) 980 except: 981 # Cleanup if the child failed starting.

File /opt/conda/lib/python3.10/subprocess.py:1863, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session) 1862 err_msg = os.strerror(errno_num) -> 1863 raise child_exception_type(errno_num, err_msg, err_filename) 1864 raise child_exception_type(err_msg)

FileNotFoundError: [Errno 2] No such file or directory: '/home/Release-23.11.0-0/poppler-23.11.0/Library/bin/pdfinfo'

image

vvasuki commented 7 months ago

Same error with Debian Linux 12 , pdf2image version 1.17.0-

$ /usr/bin/pdfinfo
pdfinfo version 22.12.0
Copyright 2005-2022 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011, 2022 Glyph & Cog, LLC
Usage: pdfinfo [options] <PDF-file>
Traceback (most recent call last):
  File "/home/vvasuki/py_env/lib/python3.11/site-packages/pdf2image/pdf2image.py", line 581, in pdfinfo_from_path
    proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/pdfinfo'
pradhyumna85 commented 3 weeks ago

@HannaHUp Don't do the installation of poppler using pip, follow https://github.com/Belval/pdf2image/issues/142 for installation of poppler utils on system level.