Setupterm could not find terminal, in Python program using curses Setupterm could not find terminal, in Python program using curses python python

Setupterm could not find terminal, in Python program using curses


You must set enviroment variables TERM and TERMINFO, like this:

export TERM=linuxexport TERMINFO=/etc/terminfo

And, if you device have no this dir (/etc/terminfo), make it, and copy terminfo database.

For "linux", and "pcansi" terminals you can download database:


Go to run/debug configuration(the one next to Pycharm run button). Sticking on Emulate Terminal In Output Console. Then you will be able to run your program with the run button.


I found this question when searching for examples because I am also learning to use curses so I don't know much about it. I know this works though:

import cursestry:    stdscr = curses.initscr()    curses.noecho()    curses.cbreak()    stdscr.keypad(1)    while 1:        c = stdscr.getch()        if c == ord('p'):            stdscr.addstr("I pressed p")        elif c == ord('q'): breakfinally:    curses.nocbreak(); stdscr.keypad(0); curses.echo()    curses.endwin()

I also added the try: finally: to make sure I get the terminal to it's original appearance even if something simple goes wrong inside the loop.

You have to use the addstr to make sure the text is going to be displayed inside the window.