Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
curses.initscr doesn't work
#1
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
Reply
#2
Did you run the program in a terminal or in a python IDE?
Reply
#3
(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
Reply
#4
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I want to be able to scroll up in curses to see previous text. Caiden 1 761 Jul-28-2023, 01:15 PM
Last Post: deanhystad
  Why doesn't calling a parent constructor work with arbitrary keyword arguments? PurposefulCoder 4 944 Jun-24-2023, 02:14 PM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,795 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  color code doesn't work harryvl 1 893 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  client.get_all_tickers() Doesn't work gerald 2 1,719 Jun-16-2022, 07:59 AM
Last Post: gerald
  pip doesn't work after Python upgrade Pavel_47 10 4,226 May-30-2022, 03:31 PM
Last Post: bowlofred
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 2,021 Dec-18-2021, 02:38 AM
Last Post: knight2000
  Class Method to Calculate Age Doesn't Work gdbengo 1 1,712 Oct-30-2021, 11:20 PM
Last Post: Yoriz
  Process doesn't work but Thread work ! mr_byte31 4 2,635 Oct-18-2021, 06:29 PM
Last Post: mr_byte31
  Psycopg2 doesn't work with python2 MedianykEugene 3 2,965 Aug-10-2021, 07:00 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020