belval / pdf2image-as-a-service Goto Github PK
View Code? Open in Web Editor NEWDeploying a basic application on GCP, AWS and Azure
License: MIT License
Deploying a basic application on GCP, AWS and Azure
License: MIT License
While running on an Apline docker, I'm getting the error:
`Traceback (most recent call last):
File "venv/lib/python3.10/site-packages/pdf2image/pdf2image.py", line 568, in pdfinfo_from_path
proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 966, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1842, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'poppler_binaries/pdfinfo'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "utils.py", line 94, in pdf_to_images
return convert_from_bytes(
File "venv/lib/python3.10/site-packages/pdf2image/pdf2image.py", line 358, in convert_from_bytes
return convert_from_path(
File "venv/lib/python3.10/site-packages/pdf2image/pdf2image.py", line 127, in convert_from_path
page_count = pdfinfo_from_path(
File "venv/lib/python3.10/site-packages/pdf2image/pdf2image.py", line 594, in pdfinfo_from_path
raise PDFInfoNotInstalledError(
pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
Traceback (most recent call last):
File "venv/lib/python3.10/site-packages/pdf2image/pdf2image.py", line 568, in pdfinfo_from_path
proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 966, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1842, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'poppler_binaries/pdfinfo'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "utils.py", line 94, in pdf_to_images
return convert_from_bytes(
File "venv/lib/python3.10/site-packages/pdf2image/pdf2image.py", line 358, in convert_from_bytes
return convert_from_path(
File "venv/lib/python3.10/site-packages/pdf2image/pdf2image.py", line 127, in convert_from_path
page_count = pdfinfo_from_path(
File "venv/lib/python3.10/site-packages/pdf2image/pdf2image.py", line 594, in pdfinfo_from_path
raise PDFInfoNotInstalledError(
pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
`
I had trouble running ldconfig when running your build_poppler.sh script. One work around I found was to use apt-get to download poppler directly and cp the relative dependencies using locate.
I can open a PR if that would be something you would find useful.
Hi, do you have the memory limit problem using pdf2img script to convert pdf to images in aws lambda?
Currently the lambda example will break if the pip version / environment uses Python 3.7, which is not the same as lambda, that uses 3.6. This hinders reproducibility. It should be deployed from a docker container.
I'm trying to make this work on AWS Lambda. I'm following the instructions in the README and running the scripts in an AWS instance with the same Amazon-Linux image used by Lambda.
Problem is, when testing the function I get the following error:
pdf2image.exceptions.PDFPageCountError: Unable to get page count. poppler_binaries/pdfinfo: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory
What could be the cause? Am I doing something wrong?
Hi,
I am trying to install poppler binaries on aws lambda using your as-a-function amazon guide.
The directory poppler_binaries is being created but it is empty. Can you please tell how to resolve it?
Hi,
you may want to include DigitalOcean as well.
There is this thing called doctl, the Official DigitalOcean Command-Line Client.
Continue the great work!
Hello , I tried installing the poppler as per the docker file and deployed the layer. When I try using pdf2image in code , this is what happening , its working fine on my local machine but on lambda I'm getting error . libpoppler.so.73 is there in the layer along with all the other binaries .
Added traceback for the reference :
Traceback (most recent call last):
File \"/var/task/pdf2image/pdf2image.py\", line 473, in pdfinfo_from_path
raise ValueError
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File \"/var/task/services/test/pdf2tiffmanager.py\", line 52, in convert_pdf_tiff
images = convert_from_path(local_save_path, fmt='tiff', use_pdftocairo=True)
File \"/var/task/pdf2image/pdf2image.py\", line 98, in convert_from_path
page_count = pdfinfo_from_path(pdf_path, userpw, poppler_path=poppler_path)[\"Pages\"]
File \"/var/task/pdf2image/pdf2image.py\", line 482, in pdfinfo_from_path
raise PDFPageCountError(
pdf2image.exceptions.PDFPageCountError: Unable to get page count.
pdfinfo: error while loading shared libraries: **libpoppler.so.73: cannot open shared object file: No such file or directory**
Regards
Ankur
[ERROR] PDFPageCountError: Unable to get page count.
poppler_binaries/pdfinfo: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by poppler_binaries/libexpat.so.1)
I am using python3.7 for aws lambda runtime.
Does anyone have any idea?
I get the following error when I try to use pdf2image following your example:
[ERROR] PDFPageCountError: Unable to get page count.
pdfinfo: /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /opt/lib/libpng16.so.16)
Traceback (most recent call last):
File "/var/task/index.py", line 33, in handler
text = extract_text_pdf(image_path)
File "/var/task/index.py", line 119, in extract_text_pdf
imgs = pdf2image.convert_from_path(image_path, output_folder=path)
File "/opt/python/lib/python3.8/site-packages/pdf2image/pdf2image.py", line 97, in convert_from_path
page_count = pdfinfo_from_path(pdf_path, userpw, poppler_path=poppler_path)["Pages"]
File "/opt/python/lib/python3.8/site-packages/pdf2image/pdf2image.py", line 471, in pdfinfo_from_path
raise PDFPageCountError(
Hi,
After deploying it to the AWS Lambda using your sh script I got the error:
Unable to import module 'pdf2image_demo': cannot import name '_imaging'
What could cause it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.