0

Found out about Curses a couple days ago and wanted to start messing around with it to see what I could create. I followed some instructions for installation on another thread and it installed just fine. However, when I attempt to run initscr() (which initializes the screen, it crashes)

Here's the Error text:

{Traceback (most recent call last): File "C:\Users\ADimi\Desktop\Wing Workspace\test.py", line 2, in <module> stdscr = curses.initscr() File "C:\Users\ADimi\AppData\Local\Programs\Python\Python37\lib\curses\__init__.py", line 30, in initscr fd=_sys.__stdout__.fileno()) AttributeError: 'NoneType' object has no attribute 'fileno'}

To recreate:

You can run this in either, idle or a seperate file. For me this directly causes the error, specficially line 2. stdscr = curses.initscr()

import curses stdscr = curses.initscr()

From what I'm understanding from the error itself, _sys.__stdout__ is returning a NoneType and thus leading to a crash.

I tried to find similar issues online and have had no luck. Any help at this point could help out a lot I'd love to get this working.

Here's a link about curses: https://docs.python.org/2/howto/curses.html#curses-howto

Here's where I found out about curses, the first comment is the installation instructions I followed: What is needed for curses in Python 3.4 on Windows7?

Thanks in advance.

EDIT: I have some what found a fix. There is a windows tailored version of curses found here: https://pypi.org/project/windows-curses/#files

After uninstalling the old curses and installing this you must follow some intermediate steps:

Create a file with this test code:

import curses
import time

screen = curses.initscr()
screen.clear()

time.sleep(4)

Create a path for 'python' for your cmd prompt: https://www.pythoncentral.io/add-python-to-path-python-is-not-recognized-as-an-internal-or-external-command/

Now using the cmd prompt open the file:

python test.py

You should be presented with a black screen for 4 seconds, then it will close.

This is the only work around I've come across, I will keep searching and updating as I go thank you.

Andrew D
  • 1
  • 2
  • Copy and paste your errors as text, not as an image. Also, please include a [mcve]. – Jonathon Reinhart Jan 11 '19 at 00:43
  • How did you install curses? – thebjorn Jan 11 '19 at 00:52
  • @thebjorn I found the appropriate package here: https://www.lfd.uci.edu/~gohlke/pythonlibs/ Then, using the cmd console I ran the wheel file and it installed. – Andrew D Jan 11 '19 at 00:54
  • 1
    I don't think you're ever going to get `curses` working inside IDLE, as you're not talking to a real terminal. But this failure in a standalone script is puzzling. Wild guess: try `import sys; sys.__stdout__ = sys.stdout` at the top, that should at least bypass the immediate error. – jasonharper Jan 11 '19 at 03:04
  • @jasonharper that does appear to bypass the immediate error, but a new error appears. It claims unsupported operation for fileno. I did some digging online and managed to find some claims backing what you said. It appears that it just doesn't work on idle. I am however, able to launch successfully in command line – Andrew D Jan 11 '19 at 03:20

0 Answers0