WongKinYiu / yolov7

Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
GNU General Public License v3.0
13.19k stars 4.17k forks source link

cv2 import version issue #1244

Open hsinhoyeh opened 1 year ago

hsinhoyeh commented 1 year ago

Hi, thanks for creating this amazing project. some issue when I build yolov7 with cv2 package(as you can see the log below), seems that the cv2 package has broken in the latest release (e.g. opencv-python-4.6.0.66) while the previous version is working (e.g.opencv-python==4.5.5.64)

as for requirement.txt (https://github.com/WongKinYiu/yolov7/blob/main/requirements.txt#L6), it is always the best practice to be able to ping a specific version as possible, pinging with minimum version could introduce future breaking due to situation like this.

-opencv-python>=4.1.1
+opencv-python==4.5.5.64
  File "/workspace/detect.py", line 5, in <module>
    import cv2
  File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 175, in bootstrap
    if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
  File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
    py_module = importlib.import_module(module_name)
  File "/opt/conda/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/conda/lib/python3.8/site-packages/cv2/gapi/__init__.py", line 290, in <module>
    cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)