when i execute my face recognition training program python stops working [closed]

  c++, face-recognition, python, redistributable

Hello guys, i have a problem with my face recognition training
program, when i execute it show me this error.

window 1

and then a second window shows up. When i close those two windows the program stop executing, and the data set is trainned because the program can eventually identify the faces in front of the camera. Now i want to create an .exe file and i think this error should be solved to make a .exe
window 2

i’ve tried to install all C++ Redistributable Packages but it didn’t
work at all. Here’s the code:

import os
import numpy as np
from PIL import Image
import cv2
import pickle

y_labels = []
x_train = []
current_id = 0
label_ids = {}

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
image_dir = os.path.join(BASE_DIR, "my_training_face")
face_cascade = cv2.CascadeClassifier("C://Users/poste/PycharmProjects/untitled2/data/haarcascade_frontalface_alt2.xml")
recognizer = cv2.face.LBPHFaceRecognizer_create()
for root, dirs, files in os.walk(image_dir):
    for file in files:
        if file.endswith("png") or file.endswith("jpg") or file.endswith("jpeg"):
            path = os.path.join(root, file)
            label = os.path.basename(os.path.dirname(path))

            if not label in label_ids:
                current_id += 1

            pil_image = Image.open(path).convert("L")   
            image_array = np.array(pil_image, "uint8")  
            faces = face_cascade.detectMultiScale(image_array, scaleFactor=1.5, minNeighbors=5)

            for(x,y,h,w) in faces:
                roi=image_array[y:y+h, x:x+w]

with open("labels.pickle",'wb') as f:

recognizer.train(x_train, np.array(y_labels))

Source: Windows Questions C++