Ask Your Question

Revision history [back]

ERROR: recursion is detected during loading of "cv2" binary extensions

I installed cv2 in release mode and everything is fine. Now I want to debug my python and C++ code (https://docs.microsoft.com/en-us/visualstudio/python/debugging-mixed-mode-c-cpp-python-in-visual-studio?view=vs-2017) Now instead of release mode I install cv2 in debug mode : I copy build\opencv\lib\python3\Debug\cv2.cp37-win_amd64.pyd in I have got eror :

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

error is thrown by Python\Lib\site-packages\cv2__init__.py :

import sys
if hasattr(sys, 'OpenCV_LOADER'):
    print(sys.path)
    raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')
sys.OpenCV_LOADER = True

What is problem with my install in debug?

ERROR: recursion is detected during loading of "cv2" binary extensions

I installed cv2 in release mode and everything is fine. Now I want to debug my python and C++ code (https://docs.microsoft.com/en-us/visualstudio/python/debugging-mixed-mode-c-cpp-python-in-visual-studio?view=vs-2017) Now instead of release mode I install cv2 in debug mode : I copy build\opencv\lib\python3\Debug\cv2.cp37-win_amd64.pyd in I have got eror :

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

error is thrown by Python\Lib\site-packages\cv2__init__.py :

import sys
if hasattr(sys, 'OpenCV_LOADER'):
    print(sys.path)
    raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')
sys.OpenCV_LOADER = True

What is problem with my install in debug?

Python trace

Loaded '__main__'
Loaded 'cv2.load_config_py3'
Loaded 'cv2'
['F:\\Cours\\TFCours\\Python\\ExemplePython\\Stereo', '', 'F:\\Cours\\TFCours\\Python\\ExemplePython\\', 'F:\\Program Files\\Python\\python37.zip', 'F:\\Program Files\\Python\\DLLs', 'F:\\Program Files\\Python\\lib', 'F:\\Program Files\\Python', 'F:\\Program Files\\Python\\lib\\site-packages']

Traceback (most recent call last):
  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\ptvsd_launcher.py", line 119, in <module>

vspd.debug(filename, port_num, debug_id, debug_options, run_as)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\debugger.py", line 37, in debug

run(address, filename, *args, **kwargs)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_local.py", line 64, in run_file

run(argv, addr, **kwargs)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_local.py", line 125, in _run

_pydevd.main()

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1752, in main

globals = debugger.run(setup['file'], None, None, is_module)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1099, in run

return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1106, in _exec

pydev_imports.execfile(file, globals, locals)  # execute the script

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile

exec(compile(contents+"\n", file, 'exec'), glob, loc)

  File "F:\Cours\TFCours\Python\ExemplePython\Stereo\stereo.py", line 2, in <module>

import cv2 as cv

  File "F:\Program Files\Python\lib\site-packages\cv2\__init__.py", line 89, in <module>

bootstrap()

  File "F:\Program Files\Python\lib\site-packages\cv2\__init__.py", line 79, in bootstrap

import cv2

  File "F:\Program Files\Python\lib\site-packages\cv2\__init__.py", line 89, in <module>

bootstrap()

  File "F:\Program Files\Python\lib\site-packages\cv2\__init__.py", line 23, 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.

The thread 'MainThread' (0x1) has exited with code 0 (0x0).
The program 'python.exe' has exited with code 0 (0x0).

ERROR: recursion is detected during loading of "cv2" binary extensions

I installed cv2 in release mode and everything is fine. Now I want to debug my python and C++ code (https://docs.microsoft.com/en-us/visualstudio/python/debugging-mixed-mode-c-cpp-python-in-visual-studio?view=vs-2017) Now instead of release mode I install cv2 in debug mode : I copy build\opencv\lib\python3\Debug\cv2.cp37-win_amd64.pyd in I have got eror :

Unhandled exception at 0x0000000065CC9E02 (python36_d.dll) in python.exe: 0xC0000005: Access violation reading location 0x0000000000000025. occurred

stack trace is : python36_d.dll!PyUnicode_InternInPlace(_object * * p) Line 15272 C python36_d.dll!PyUnicode_InternFromString(const char * cp) Line 15307 C python36_d.dll!PyImport_Import(_object * module_name) Line 1711 C python36_d.dll!PyImport_ImportModule(const char * name) Line 1257 C cv2.cp36-win_amd64.pyd!_import_array() Line 1466 C++

ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.cv2.cp36-win_amd64.pyd!PyInit_cv2() Line 1785 C++ [External Code] <frozen importlib._bootstrap="">!_call_with_frames_removed Line 219 Python <frozen importlib._bootstrap_external="">!create_module Line 922 Python <frozen importlib._bootstrap="">!module_from_spec Line 571 Python <frozen importlib._bootstrap="">!_load_unlocked Line 658 Python <frozen importlib._bootstrap="">!_find_and_load_unlocked Line 955 Python <frozen importlib._bootstrap="">!_find_and_load Line 971 Python colorRange.py!<module> Line 2 Python

error is thrown by Python\Lib\site-packages\cv2__init__.py my program is :

import sys
if hasattr(sys, 'OpenCV_LOADER'):
    print(sys.path)
    raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')
sys.OpenCV_LOADER = True

What is problem with my install in debug?

Python trace

Loaded '__main__'
Loaded 'cv2.load_config_py3'
Loaded 'cv2'
['F:\\Cours\\TFCours\\Python\\ExemplePython\\Stereo', '', 'F:\\Cours\\TFCours\\Python\\ExemplePython\\', 'F:\\Program Files\\Python\\python37.zip', 'F:\\Program Files\\Python\\DLLs', 'F:\\Program Files\\Python\\lib', 'F:\\Program Files\\Python', 'F:\\Program Files\\Python\\lib\\site-packages']

Traceback (most recent call last):
  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\ptvsd_launcher.py", line 119, in <module>

vspd.debug(filename, port_num, debug_id, debug_options, run_as)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\debugger.py", line 37, in debug

run(address, filename, *args, **kwargs)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_local.py", line 64, in run_file

run(argv, addr, **kwargs)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_local.py", line 125, in _run

_pydevd.main()

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1752, in main

globals = debugger.run(setup['file'], None, None, is_module)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1099, in run

return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1106, in _exec

pydev_imports.execfile(file, globals, locals)  # execute the script

  File "c:\program files (x86)\microsoft visual studio\2017\enterprise\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile

exec(compile(contents+"\n", file, 'exec'), glob, loc)

  File "F:\Cours\TFCours\Python\ExemplePython\Stereo\stereo.py", line 2, in <module>
numpy as np 
import cv2 as cv

  File "F:\Program Files\Python\lib\site-packages\cv2\__init__.py", line 89, in <module>

bootstrap()

  File "F:\Program Files\Python\lib\site-packages\cv2\__init__.py", line 79, in bootstrap

import cv2

  File "F:\Program Files\Python\lib\site-packages\cv2\__init__.py", line 89, in <module>

bootstrap()

  File "F:\Program Files\Python\lib\site-packages\cv2\__init__.py", line 23, 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.

The thread 'MainThread' (0x1) has exited with code 0 (0x0).
The program 'python.exe' has exited with code 0 (0x0).
cv # <-- EXception  is here
img = cv.imread("g:/lib/opencv/samples/data/baboon.jpg")

ERROR: recursion is detected during loading of "cv2" binary extensionsHow to debug C++ code in a python program using VS2017?

I installed cv2 in release mode and everything is fine. Now I want to debug my python and C++ code (https://docs.microsoft.com/en-us/visualstudio/python/debugging-mixed-mode-c-cpp-python-in-visual-studio?view=vs-2017) Now instead of release mode I install cv2 in debug mode : I copy build\opencv\lib\python3\Debug\cv2.cp37-win_amd64.pyd build\opencv\lib\python3\Debug\cv2.cp36-win_amd64.pyd in I have got eror :

Unhandled exception at 0x0000000065CC9E02 (python36_d.dll) in python.exe: 0xC0000005: Access violation reading location 0x0000000000000025. occurred

stack trace is : python36_d.dll!PyUnicode_InternInPlace(_object * * p) Line 15272 C python36_d.dll!PyUnicode_InternFromString(const char * cp) Line 15307 C python36_d.dll!PyImport_Import(_object * module_name) Line 1711 C python36_d.dll!PyImport_ImportModule(const char * name) Line 1257 C cv2.cp36-win_amd64.pyd!_import_array() Line 1466 C++

cv2.cp36-win_amd64.pyd!PyInit_cv2() Line 1785 C++ [External Code] <frozen importlib._bootstrap="">!_call_with_frames_removed Line 219 Python <frozen importlib._bootstrap_external="">!create_module Line 922 Python <frozen importlib._bootstrap="">!module_from_spec Line 571 Python <frozen importlib._bootstrap="">!_load_unlocked Line 658 Python <frozen importlib._bootstrap="">!_find_and_load_unlocked Line 955 Python <frozen importlib._bootstrap="">!_find_and_load Line 971 Python colorRange.py!<module> Line 2 Python

my program is :

import numpy as np 
import cv2 as cv # <-- EXception  is here
img = cv.imread("g:/lib/opencv/samples/data/baboon.jpg")