'Pythonanywhere - Exception: Unable to get page count. Is poppler installed and in PATH?

I am converting pdf to image and using the module pdf2image for this. The code is working fine on my computer but its throwing this error when I run the script on pythonanywhere.

No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/home/raj769417/.local/lib/python3.9/site-packages/pdf2image/pdf2image.py", line 458, in pdfinfo_from_path
    proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE)
   File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '\\\\Release-22.01.0-0\\\\poppler-22.01.0\\\\Library\\\\bin/pdfinfo'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/raj769417/.local/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 555, in process_update
    handler.handle_update(update, self, check, context)
  File "/home/raj769417/.local/lib/python3.9/site-packages/telegram/ext/handler.py", line 198, in handle_update
    return self.callback(update, context)
  File "/home/raj769417/telegram_bot/telegram-bot.py", line 66, in data_to_modify
    modify_document_and_send(modification_details, update, context)
  File "/home/raj769417/telegram_bot/telegram-bot.py", line 73, in modify_document_and_send
    modify.start_process()
  File "/home/raj769417/telegram_bot/./main.py", line 108, in start_process
    all_images = self.pdf_to_image()
  File "/home/raj769417/telegram_bot/./main.py", line 93, in pdf_to_image
    all_images = convert_from_path(self.file_path,
  File "/home/raj769417/.local/lib/python3.9/site-packages/pdf2image/pdf2image.py", line 98, in convert_from_path
    page_count = pdfinfo_from_path(pdf_path, userpw, poppler_path=poppler_path)["Pages"]
  File "/home/raj769417/.local/lib/python3.9/site-packages/pdf2image/pdf2image.py", line 484, in pdfinfo_from_path
    raise PDFInfoNotInstalledError(
pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?

Note : In my computer too I have not added poppler to path instead I have explicitly provided the poppler path like this and is working fine:

POPPLER_PATH = "Release-22.01.0-0\\poppler-22.01.0\\Library\\bin"
all_images = convert_from_path(self.file_path, poppler_path=POPPLER_PATH)

But the same is not working on pythonanywhere, what should I do ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source