Is there any alternative of the curses module for python to use in windows? I looked up in the python documentation, but there its mentioned that its for using in unix. I am not much familiar with these, so is there some way to use curses module in windows or is there some similar module specially for windows? [I am using Python 3.3]
-
2I have had success with the binaries posted here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses They don't have one for Python 3.3 though. – Matt Feb 08 '13 at 19:00
-
1Is this for your own use? Can you use `Cygwin`? – salezica Feb 08 '13 at 19:02
-
I am not much familiar with cygwin or unix or linux. I mainly work in windows. – Chandan Feb 08 '13 at 19:04
-
1If you don't work with linux, how about a real GUI? Qt is nice – JBernardo Feb 08 '13 at 19:04
-
Thanks. I am checking it. – Chandan Feb 08 '13 at 19:05
-
PyGTK, wxPython and some others are great starters! – Torxed Feb 08 '13 at 19:12
-
Check this http://inventwithpython.com/pygcurse/ – ionelmc Jun 21 '13 at 07:21
-
Well, there's also PDCurses: http://stackoverflow.com/questions/138153/is-ncurses-available-for-windows – Ehtesh Choudhury Sep 30 '13 at 21:10
-
@JBernardo Implying that linux has no GUI, haha (just kidding, though when you put it that way...) – Thomas Jan 04 '14 at 07:09
7 Answers
I'm happy to report that there's now a Windows build of Curses available as an extension for Python on Windows, from here. (I didn't write it, and I don't know who maintains it.)
You can run the installer, and import curses
to get curses running. (Verified on 64-bit Windows 7 and Windows 8.)
@ArtOfWarfare points out that you can install this via Pip with this commend:
pip install http://www.lfd.uci.edu/~gohlke/pythonlibs/xugyqnq9/curses-2.2-cp27-none-win32.whl

- 9,925
- 16
- 73
- 124
-
3@MarcelWilson I can't take credit for providing this. I'm just happy that I myself found this option :) – ashes999 Nov 20 '13 at 17:27
-
2I came across the same site for my python curses uses, as well as many other libraries! – Cold Diamondz Jun 18 '14 at 13:16
-
Will code written using this module work interchangeably with the module of the same name included by default with Python for other platforms, or will I need to make two versions of my code to make it work on both Windows and other platforms? – ArtOfWarfare Feb 05 '15 at 21:05
-
@ArtOfWarfare I'm not sure to both your questions. If you find out, please let me know so I can update my answer. My guess is that: a) both interfaces of curses are similar, but will have differences; and b) PDCurses is for Windows only. You may want to look at `ncurses` if you want something cross-platform. – ashes999 Feb 06 '15 at 14:36
-
PDCurses is designed to emulate various curses implementations. As you can see [here](http://pdcurses.sourceforge.net/doc/PDCurses.txt) it will generally tell you when you are straying from each standard, or using a fuction that only exists in PDCurses. The notable missing feature is access to the terminfo/termcap database - e.g. functions like `tputs` - which are just stubs that return errors. – Peter Brittain Jan 05 '16 at 00:15
-
-
@DavidHoelzer it looks like it works for me. There's no installer, but the `whl` files are still there. For example: `http://www.lfd.uci.edu/~gohlke/pythonlibs/f9r7rmd8/curses-2.2-cp36-cp36m-win32.whl` – ashes999 Jan 01 '17 at 03:52
-
Yes, interesting... Going to the page works, but direct to the URL returns a 404. – David Hoelzer Jan 01 '17 at 13:09
-
@DavidHoelzer it worked for me. I had to jump through a couple of hoops to get the direct URL. Check if JS is enabled in your browser. – ashes999 Jan 02 '17 at 04:29
-
The original question was whether there is an alternative to curses on Windows.
One answer is to use the Win32 console API. You can program this directly in Python using the excellent pywin32 package if you're already familiar with the console API.
However, I found this too low level for my recent project. I was also less than keen on forcing my users to build/install PDcurses, and besides, I also find curses too low level for a modern OO language like Python too.
I have therefore put together a high level cross-platform API to do all the things most people want from their terminal/console. The asciimatics package will provide most of your input and output needs. If you're on Linux this is a more human way to program curses. If you're on Windows, the same class works as is with no external binary dependencies. See below for an example screenshot:
There are many other effects and widgets available which you can find in the gallery, but if there's an extra feature you need, let me know and I'll see what I can do.

- 13,489
- 3
- 41
- 57
Then you're out of luck i'm afraid. There's no real cross-platform version or port of curses/ncurses, there is a "dialogue" port which works, but it's limited in capabilities.
Your best bet is to run CygWin or MinGW32, both are, in "loose terms", a Linux system+terminal emulator which has much of the binaries you need. They can run native Linux/Unix binaries inside the terminal and access your "host" system files at any time, so it's like patching Windows with a kick-ass terminal with all your goodies from the Linux world. You'll still need some basic knowledge of Linux and how the commands etc work, but you'll figure it out.
Here's a Pyglet GUI example:
import pyglet
from pyglet.gl import *
class main (pyglet.window.Window):
def __init__ (self):
super(main, self).__init__(800, 600, fullscreen = False)
self.button_texture = pyglet.image.load('button.png')
self.button = pyglet.sprite.Sprite(self.button_texture)
## --- If you'd like to play sounds:
#self.sound = pyglet.media.load('music.mp3')
#self.sound.play()
self.alive = 1
def on_draw(self):
self.render()
def on_close(self):
self.alive = 0
def on_mouse_press(self, x, y, button, modifiers):
if x > self.button.x and x < (self.button.x + self.button_texture.width):
if y > self.button.y and y < (self.button.y + self.button_texture.height):
self.alive = 0
def on_key_press(self, symbol, modifiers):
if symbol == 65307: # [ESC]
self.alive = 0
def render(self):
self.clear()
self.button.draw()
self.flip()
def run(self):
while self.alive == 1:
self.render()
# -----------> This is key <----------
# This is what replaces pyglet.app.run()
# but is required for the GUI to not freeze
#
event = self.dispatch_events()
x = main()
x.run()
Here's the output of that code:
-
1Actually what I wanted was to make a program with its own GUI. So as JBernardo mentioned, I think [Pyside](http://qt-project.org/wiki/PySide) will do. – Chandan Feb 08 '13 at 19:11
-
1CygWin and MinGW will let you use curses, that's your original issue description :) You got a lot of great GUI (OpenGL) libraries out there, wxPython, PyGTK or even Pygame and Pyglet :) – Torxed Feb 08 '13 at 19:13
-
-
@Chandan Gave you a short update/example on a Pyglet script running as a GUI with a button which you can press that i've programmed to kill the application :) – Torxed Feb 08 '13 at 19:19
-
Can you help me with the installation of pyglet? I just installed it. But when I write import pyglet, it shows the following error: File "C:\Python33\lib\site-packages\pyglet\__init__.py", line 249 print '%s%s %s' % (indent, name, location) ^ SyntaxError: invalid syntax Can you please help with this? – Chandan Feb 08 '13 at 19:26
-
The only thing i can think of is that you have a 32bit Python on a 64bit OS with 64bit Pyglet installed, or vice versa.. What version of everything are you running (this will affeect whatever GUI base you choose not just Pyglet) :) – Torxed Feb 08 '13 at 19:34
-
I just installed pyglet alpha version. Its working fine now. Thanks for all the help. – Chandan Feb 08 '13 at 19:41
-
@Chandan You're welcome, (btw, most likely because you were using Python3.X only supported by the Alpha release atm) :) Don't forget to mark your question as solved if you think it is so :) – Torxed Feb 08 '13 at 20:32
-
As you can see from the other answers, your introduction is no longer true. There are genuine cross-platform options available now. – Peter Brittain Jan 25 '17 at 16:19
Here's how to install what ashes999 linked to in their answer via pip:
pip install http://www.lfd.uci.edu/~gohlke/pythonlibs/xugyqnq9/curses-2.2-cp27-none-win32.whl
This should probably be added to PyPI to make installation with pip even easier (so it could be installed by name rather than URL.)

- 1
- 1

- 20,617
- 19
- 137
- 193
-
I'm not sure why this got a DV, but anyway, I've rolled it into my answer. – ashes999 Dec 21 '15 at 21:47
-
You may try this one. I once did the Win64-port for this (merged in there). You however need to write your Python code a bit different. This one will redirect all curses calls to the native Python version on UNIX, but call PDCURSES.DLL on Windows (download the DLL separately). It supports unicode as far as I remember:

- 421
- 4
- 6
This is not a new solution, just an edit to a previous one.
In case the pip command is giving a 404 error you can try to download the packet from http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses and then write something like
pip install C:\..packetPath..\curses-2.2-cp35-none-win_amd64.whl
The official doc proposes the following (here at the bottom of the paragraph):
The Windows version of Python doesn’t include the curses module. A ported version called UniCurses is available. You could also try the Console module written by Fredrik Lundh, which doesn’t use the same API as curses but provides cursor-addressable text output and full support for mouse and keyboard input.

- 10,508
- 2
- 43
- 62