问题
I'm trying to initiate
screen = curses.initscr()
But it failed and returns
File "C:\Python32\lib\curses\__init__.py", line 31, in initscr
fd=_sys.__stdout__.fileno())
AttributeError: 'NoneType' object has no attribute 'fileno'
Here's my system Python 3.2.3 (default, Apr 11 2012, 07:12:16) [MSC v.1500 64 bit (AMD64)] on win32
This is my first time running python on this computer, it's Windows 7 64bit.
Is this has something to do with my OS? Anyway I can solve this?
回答1:
You can't use the curses
module on Windows; apparently there are DOS and OS/2 ports but it is primarily a POSIX-only library.
You'll have to use a Windows-specific port such as wcurses, a third-party project that supports Windows too such as PDCurses, or you could try the console module (the latter drives the Windows CMD console in a similar manner).
回答2:
There are curses extension down-loads available for almost all the Python versions on Windows. I had the same error as Pieters but it stemmed from the fact I was trying to run the program from Idle. That doesn't work, apparently, when using an extension like curses. Just left click on your .py program and it will make its own call to Python and its extensions and this error goes away.
来源:https://stackoverflow.com/questions/13434514/python-curses-initscr-error