Import cv2 error - September 2023

Getting the below error :

File β€œ/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 552, in _run_script
exec(code, module.dict)
File β€œ/mount/src/donut_annotation_tool/main.py”, line 4, in
from doctr.models import ocr_predictor
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/doctr/init.py”, line 1, in
from . import datasets, io, models, transforms, utils
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/doctr/datasets/init.py”, line 3, in
from .generator import *
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/doctr/datasets/generator/init.py”, line 6, in
from .pytorch import * # type: ignore[misc]
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/doctr/datasets/generator/pytorch.py”, line 8, in
from .base import _CharacterGenerator, _WordGenerator
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/doctr/datasets/generator/base.py”, line 11, in
from doctr.io.image import tensor_from_pil
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/doctr/io/init.py”, line 1, in
from .elements import *
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/doctr/io/elements.py”, line 19, in
from doctr.utils.common_types import BoundingBox
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/doctr/utils/init.py”, line 3, in
from .geometry import *
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/doctr/utils/geometry.py”, line 10, in
import cv2
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/cv2/init.py”, line 181, in
bootstrap()
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/cv2/init.py”, line 175, in bootstrap
if __load_extra_py_code_for_module(β€œcv2”, submodule, DEBUG):
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/cv2/init.py”, line 28, in __load_extra_py_code_for_module
py_module = importlib.import_module(module_name)
File β€œ/usr/local/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File β€œ/home/adminuser/venv/lib/python3.9/site-packages/cv2/gapi/init.py”, line 301, in
cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline

requirements.txt:

numpy
torch
Pillow
streamlit
streamlit_float
python-doctr
doctr
opencv-contrib-python
opencv-python-headless==4.5.4.60

tried adding opencv-python-headless and still not working

try to install using this opencv

pip install opencv-python

Tried this at the first place - it was not working

Please do not hijack a thread, that is another topic.
Search for talib here, there you will find a few threads:

https://discuss.streamlit.io/tag/talib

1 Like

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