Python Forum
Curses could not find terminal
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Curses could not find terminal
#6
You have launched a fork bomb. You'd better shutdown and reboot. It's not the three lines you just posted that open and close many terminals. Can you post the real code?

Here is a full code that works for me in linux, but the terminal application is konsole, which has its own options

import argparse
import subprocess
import sys

def main_work(args):
    print('Hello from term-example')

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--noterminal',
        help="don't start a new terminal'",
        action='store_true')
    ns = parser.parse_args()
    try:
        sys.stdout.fileno()
    except Exception:
        # not a terminal for sure
        if ns.noterminal:
            raise RuntimeError('Need a terminal to run.')
        else:
            subprocess.call(['konsole', '--noclose', '-e', sys.executable, __file__, '--noterminal'])
    else:
        main_work(ns)

    
if __name__ == '__main__':
    main()
When I run this code in a terminal, it simply executes the code in main_work(). When I run it from IDLE3 by pressing the F5 key, it launches a new console and executes the code from main_work() in this console.

The konsole command has an option --noclose so that it stays here after the execution of
the code. An alternative is to add a command that waits at the end, such as if ns.noterminal: input()
Reply


Messages In This Thread
Curses could not find terminal - by Solstice - Jan-04-2018, 02:18 PM
RE: Curses could not find terminal - by Gribouillis - Jan-04-2018, 04:13 PM
RE: Curses could not find terminal - by Solstice - Jan-04-2018, 04:22 PM
RE: Curses could not find terminal - by Gribouillis - Jan-04-2018, 04:32 PM
RE: Curses could not find terminal - by Solstice - Jan-04-2018, 05:27 PM
RE: Curses could not find terminal - by Gribouillis - Jan-04-2018, 06:25 PM
RE: Curses could not find terminal - by Solstice - Jan-04-2018, 08:02 PM
RE: Curses could not find terminal - by Gribouillis - Jan-04-2018, 08:57 PM
RE: Curses could not find terminal - by Solstice - Jan-05-2018, 01:56 PM
RE: Curses could not find terminal - by Gribouillis - Jan-05-2018, 03:28 PM
RE: Curses could not find terminal - by sparkz_alot - Jan-05-2018, 04:01 PM
RE: Curses could not find terminal - by Gribouillis - Jan-05-2018, 04:23 PM
RE: Curses could not find terminal - by sparkz_alot - Jan-05-2018, 04:56 PM
RE: Curses could not find terminal - by Gribouillis - Jan-06-2018, 07:56 AM

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 859 Jul-28-2023, 01:15 PM
Last Post: deanhystad
  curses issue otalado 2 2,847 Jun-29-2021, 02:07 PM
Last Post: tmz
  How to make curses.border() use A_BOLD atttribute? pjfarley3 0 4,983 Feb-03-2021, 11:22 PM
Last Post: pjfarley3
  Curses script doesn't work wavic 1 4,266 Jan-08-2021, 09:11 PM
Last Post: wavic
  Why aren't all curses panel functions supported in python curses.panel? pjfarley3 2 2,755 Jul-22-2020, 11:08 PM
Last Post: pjfarley3
  curses library autompav96 2 2,972 Mar-02-2019, 02:12 AM
Last Post: woooee
  curses key codes not working jgrillout 0 3,086 Feb-11-2019, 01:46 AM
Last Post: jgrillout
  Pretty table and curses? MuntyScruntfundle 0 2,969 Oct-16-2018, 10:22 AM
Last Post: MuntyScruntfundle
  curses.initscr doesn't work zaphod424 3 9,949 Feb-28-2018, 12:36 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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