Import cv2 fails

there was a close post re: docker (but of corse it’s not docker).

here’s the error…

[23:54:28] 🐍 Python dependencies were installed from /app/plainsight-classification/requirements.txt using pip.

Check if streamlit is installed

Streamlit is already installed

[23:54:29] 📦 Processed dependencies!




2022-07-03 23:54:40.113 Uncaught app exception

Traceback (most recent call last):

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 554, in _run_script

    exec(code, module.__dict__)

  File "ps_classification.py", line 6, in <module>

    import cv2

  File "/home/appuser/venv/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module>

    bootstrap()

  File "/home/appuser/venv/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap

    native_module = importlib.import_module("cv2")

  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

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

2022-07-03 23:57:47.175 Uncaught app exception

Traceback (most recent call last):

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 554, in _run_script

    exec(code, module.__dict__)

  File "ps_classification.py", line 6, in <module>

    import cv2

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

2022-07-04 00:03:27.836 Uncaught app exception

Traceback (most recent call last):

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 554, in _run_script

    exec(code, module.__dict__)

  File "ps_classification.py", line 6, in <module>

    import cv2

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

and the contents of requirements.txt

numpy==1.21.6
opencv_python==4.6.0.66
requests==2.28.1
streamlit==1.10.0
1 Like

Use this for opencv instead:

opencv-python-headless==4.5.4.60
1 Like

was digging around and found that i also needed a packages.txt file.

Contents for that file was ‘python3-opencv’.

Once uploaded to the repo, worked like a charm. closing.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.