Python Forum

Full Version: curses.initscr doesn't work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
so Ive written a program, using the curses module to open a window, however when I run it I get an error message:



Error:
Traceback (most recent call last): File "/Users/alex/Documents/Programming things/game.py", line 10, in <module> s = curses.initscr() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/curses/__init__.py", line 30, in initscr fd=_sys.__stdout__.fileno()) _curses.error: setupterm: could not find terminal
the first few lines of the program, where the problem lies, are:

import random
import curses

s = curses.initscr()
curses.curs_set(0)
sh, sw = s.getmaxyx()
window = curses.newwin(sh, sw, 0,0)
window.keypad(1)
window.timeout(100)
unless ive just missed something, (im fairly new to python, so this is very possible) I can't see whats gone wrong, and why it fails to find the terminal.

im using python 3.6, and running it on OSX 10.13.3
Did you run the program in a terminal or in a python IDE?
(Feb-28-2018, 07:39 AM)Gribouillis Wrote: [ -> ]Did you run the program in a terminal or in a python IDE?
yes I used both the pycharm IDE and IDLE, both gave the same error
Curses won't normally work in an IDE. It works only if you are running the python program from a terminal. Open a terminal and type
Output:
python3 /Users/alex/Documents/Programming things/game.py
(you may have to replace python3 with /Library/Frameworks/Python.framework/Versions/3.6/bin/python for example)