How to debug C++ code in a python program using VS2017?

asked 2018-12-23 12:20:51 -0500

LBerger gravatar image

updated 2018-12-24 04:53:36 -0500

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/visu...) Now instead of release mode I install cv2 in debug mode : I copy 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")
edit retag flag offensive close merge delete

Comments

@LBerger, Python3 is 64-bit?

dkurt gravatar imagedkurt ( 2018-12-24 05:19:21 -0500 )edit

I think so. print( sys.version) gives

3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)]

Something weird is in dll loaded I have got python36.dll and python36_d.dll. Could it be a problem

LBerger gravatar imageLBerger ( 2018-12-24 05:26:27 -0500 )edit

I think that numpy must be compiled in debug

LBerger gravatar imageLBerger ( 2018-12-28 03:21:33 -0500 )edit