'Getting _curses.error: curses function returned NULL in windows-curses

I checked other answers but I had no luck.

So I'm doing a thing with open-cv and the terminal with windows-curses but I'm getting the _curses.error: curses function returned NULL error

I'm still a noobie with curses, therefore I have ZERO clue about why this happens

Here's the code

from string import ascii_letters
import cv2 as cv
import numpy as np
import os
import curses as cs

basefolder = os.path.dirname(os.path.abspath(__file__)).replace(os.path.basename(__file__), '') + '\\'

def map_range(value, leftMin, leftMax, rightMin, rightMax):
    # Figure out how 'wide' each range is
    leftSpan = leftMax - leftMin
    rightSpan = rightMax - rightMin

    # Convert the left range into a 0-1 range (float)
    valueScaled = float(value - leftMin) / float(leftSpan)

    # Convert the 0-1 range into a value in the right range.
    return rightMin + (valueScaled * rightSpan)

def asciify(matrix):
    w, h = len(matrix[0]), len(matrix)
    
    asciis = '$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,"^`\'.'
    output = np.empty(shape=(h, w), dtype=str)

    for i in range(h):
        for j in range(w):
            asc = map_range(matrix[i, j], 255, 0, len(asciis)-1, 0)
            output[i, j] = asciis[int(asc)]





    return output


def main(stdscr):

    cs.initscr()

    img = cv.imread(basefolder + 'cat.jpg', 0)
    ascii_img = asciify(img)

    w, h = len(ascii_img[0]), len(ascii_img)

    win = cs.newwin(h, w, 0, 0)

    win.clear()
    
    for i in range(h):
        strg = []
        for j in range(w):
            strg.append(ascii_img[i, j])
        
        win.addstr(i, 0, ''.join(strg))


    win.refresh()
    stdscr.getch()

cs.wrapper(main)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source