Python curses Redirection is not supported

♀尐吖头ヾ 提交于 2020-01-12 14:05:42

问题


I am trying to use Curses in PyDev in Eclipse in Win7.

I have installed Python 3.2 (64bit) and curses-2.2.win-amd64-py3.2. When I input the following testing codes into PyDev:

import curses  

myscreen = curses.initscr()
myscreen.border(0)
myscreen.addstr(12, 25, "Python curses in action!")    
myscreen.refresh()
myscreen.getch()     
curses.endwin()

It did not show any syntax error, so I think the curses was installed correctly.

However, when I ran it as Python Run, the output showed: Redirection is not supported. I do not know where this problem comes from. I googled a lot but can't find related information.


回答1:


You cannot expect to use curses with a non-terminal.

Probably you get this because you are running the script from inside an IDE, like PyCharm or any other.

All IDEs do provide consoles that are not terminals, so that's where the problem comes from.




回答2:


Recent PyCharm versions (I am currently running 2017.2, not sure when this option was added, or if it has been there the entire time) have the option "Emulate terminal in output console". Curses works with this option checked.




回答3:


You can't use any IDE to run python files with the curses package. I used to run in pycharm and naturally couldn't run.

Change to the command line to run:

for testing follow my following steps

  1. on desktop open notepad and copy paste the code and save it as filename.py
  2. open command line change directory to desktop use below command cd Desktop and hit enter type python example.py and hit enter, your program will definitely run


来源:https://stackoverflow.com/questions/16740385/python-curses-redirection-is-not-supported

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