pycallgraph2 icon indicating copy to clipboard operation
pycallgraph2 copied to clipboard

ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.

Open sanbuphy opened this issue 2 years ago • 0 comments

Hello friends, I really like the functionality of this program. I encountered an error during the running process:(This problem only occurs after using pycallgraph) pycallgraph graphviz -- ./mytest.py

This is a bit deep learning library that it have used the opencv library.

from mmdet.apis import init_detector, inference_detector
from mmdet.utils import register_all_modules
from mmdet.registry import VISUALIZERS
import mmcv
register_all_modules()
config_file = './checkpoints/yolov3_mobilenetv2_8xb24-320-300e_coco.py'
checkpoint_file = './checkpoints/yolov3_mobilenetv2_320_300e_coco_20210719_215349-d18dff72.pth'
model = init_detector(config_file, checkpoint_file, device='cpu')  # or device='cuda:0'
image = mmcv.imread( "demo/demo.jpg", channel_order='rgb')
result = inference_detector(model, image)
visualizer = VISUALIZERS.build(model.cfg.visualizer)
visualizer.dataset_meta = model.dataset_meta
visualizer.add_datasample(
    'result',
    image, 
    data_sample=result,
    draw_gt=False,
    show=False,
    wait_time=0,
)

and then i meet the error:

Traceback (most recent call last):
  File "/home/sanbu/anaconda3/envs/mmlab2/bin/pycallgraph", line 26, in <module>
    exec(__file_content)
  File "<string>", line 10, in <module>
  File "/home/sanbu/mmdetection3.x/mmdetection3/mmdet/__init__.py", line 2, in <module>
    import mmcv
  File "/home/sanbu/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmcv/__init__.py", line 4, in <module>
    from .image import *
  File "/home/sanbu/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmcv/image/__init__.py", line 2, in <module>
    from .colorspace import (bgr2gray, bgr2hls, bgr2hsv, bgr2rgb, bgr2ycbcr,
  File "/home/sanbu/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmcv/image/colorspace.py", line 4, in <module>
    import cv2
  File "/home/sanbu/anaconda3/envs/mmlab2/lib/python3.7/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/sanbu/anaconda3/envs/mmlab2/lib/python3.7/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/home/sanbu/anaconda3/envs/mmlab2/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/sanbu/anaconda3/envs/mmlab2/lib/python3.7/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/sanbu/anaconda3/envs/mmlab2/lib/python3.7/site-packages/cv2/__init__.py", line 76, in bootstrap
    raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')
ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.

Is there any way to solve this problem? Thank you very much.

sanbuphy avatar Nov 10 '22 02:11 sanbuphy