'getting_curses.error: curses function returned NULL

I get the error

(Traceback (most recent call last):
  File "C:\Users\kretz\OneDrive\Desktop\python programi\snakes\main.py", line 5, in <module>
    win = curses.newwin(20, 60, 0, 0)
_curses.error: curses function returned NULL

Process finished with exit code 1)

in the following code. Does anyone know why?

import curses


curses.initscr()
win = curses.newwin(20, 60, 0, 0)
win.keypad(1)
curses.noecho()
curses.curs_set(0)
win.border(0)
win.nodelay(1)


score = 0
while True:
    event = win.getch()
    curses.endwin()
    print(score)


Sources

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

Source: Stack Overflow

Solution Source