Import error on deployment

Hi,

I am trying to create a streamlit app to convert pdf files to doc using pdf2docx. I am getting the following error:

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

2023-11-08 19:28:55.693 Uncaught app exception

Traceback (most recent call last):

  File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 541, in _run_script

    exec(code, module.__dict__)

  File "/mount/src/pdfmodifier-streamlit/pages/pdf_to_doc.py", line 2, in <module>

    from pdf2docx import Converter

  File "/home/adminuser/venv/lib/python3.11/site-packages/pdf2docx/__init__.py", line 1, in <module>

    from .converter import Converter

  File "/home/adminuser/venv/lib/python3.11/site-packages/pdf2docx/converter.py", line 9, in <module>

    from .page.Page import Page

  File "/home/adminuser/venv/lib/python3.11/site-packages/pdf2docx/page/Page.py", line 44, in <module>

    from ..common.Collection import BaseCollection

  File "/home/adminuser/venv/lib/python3.11/site-packages/pdf2docx/common/Collection.py", line 9, in <module>

    from .algorithm import (solve_rects_intersection, graph_bfs)

  File "/home/adminuser/venv/lib/python3.11/site-packages/pdf2docx/common/algorithm.py", line 3, in <module>

    import cv2 as cv

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

I have looked around the forum and found that I needed to update ‘requirements.txt’ with ‘python-opencv-headless’ instead of ‘python-opencv’. I also tried adding ‘packages.txt’ with the following

libgl1
freeglut3-dev
libgtk2.0-dev

You can check my git repo here
The error however persists. I am a bit unsure what is wrong. Any help would be appreciated.

Thanks,

Hi @Chinmay014

In reference to the encountered error,

perhaps you can try including additional prerequisite libraries in your requirements.txt file by going over the top solutions in this related StackOverflow post:

Hope this helps!