Python Curses initscr Error

别等时光非礼了梦想. 提交于 2019-12-19 10:07:50

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!