41

I have a running Python 2.7/3.4 installation on my Windows 7 (x64) machine. I would like to test curses on Windows.

Curses is installed but not working:

>>> import curses
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Tools\Python3.4.2\lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ImportError: No module named '_curses'

The documentation says:

The Windows version of Python doesn’t include the curses module. A ported version called UniCurses is available.

So, the Windows installer of Python 3.4 installed curses with unresolved dependencies. One could name this a bug...

OK, I looked into UniCurses. It's a wrapper for PDCurses:

UniCurses is a wrapper for Python 2.x/3.x that provides a unified set of Curses functions on all platforms (MS Windows, Linux, and Mac OS X) with syntax close to that of the original NCurses. To provide the Curses functionality on Microsoft Windows systems it wraps PDCurses.

Installing UniCurses via pip3 results in an error:

C:\Users\Paebbels>pip3 install UniCurses
Downloading/unpacking UniCurses
  Could not find any downloads that satisfy the requirement UniCurses
  Some externally hosted files were ignored (use --allow-external UniCurses to allow).
Cleaning up...
No distributions at all found for UniCurses
Storing debug log for failure in C:\Users\Paebbels\pip\pip.log

The link to SourceForge on Python's UniCurses site is dead. A manual search an SourceForge helped to find UniCurses for Python again.

But, the UniCurses 1.2 installer can not find any Python installation in my Windows registry. (Python 2.7.9 and Python 3.4.2 are available).

I also looked into Public Domain Curses (PDCurses). PD Cureses 3.4 is from late 2008. So it's 7 years old. I don't believe it will work either with Windows 7 nor Windows 8.1 or Windows 10.

Is there any way to get curses running on Windows with Python.

(The Windows Python, not the CygWin Python!)

Paebbels
  • 15,573
  • 13
  • 70
  • 139
  • 1
    It probably can be made to work, since there is no basic incompatibility issue -- but going this way, you will have to learn how to modify UniCurses (and build *that*). – Thomas Dickey Sep 05 '15 at 20:33
  • 2
    Christoph Gohlke has a Windows build of [curses](http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses). Download curses‑2.2‑cp34‑none‑win_amd64.whl and follow the instructions to [install a wheel](https://pip.pypa.io/en/latest/user_guide.html#installing-from-wheels). – Eryk Sun Sep 08 '15 at 13:24
  • 2
    @eryksun Please write your comment as an answer, so I can vote on it. The installation went well. – Paebbels Sep 08 '15 at 16:56
  • 5
    Are you wedded to writing curses code, or do you need an equivalent API? If the latter, I've hit and had to solve all these same issues for [asciimatics](https://pypi.python.org/pypi/asciimatics). This package will give you a cross-terminal API that works on Windows 7, 8 and 10, plus a load of animation goodies... – Peter Brittain Nov 10 '15 at 16:39

3 Answers3

61

You can use curses cross-platform (Windows, MacOS, GNU/Linux) if you install manually for Windows or like other package in others.

  1. Install wheel package. If you need more info about wheel click here.

  2. Go to this repository.

  3. Download a package with your python version, in example for python 3.4:

    curses-2.2-cp34-none-win_amd64.whl
    
  4. Install it (this command if for windows, in GNU/Linux install like other package)

    python -m pip install curses-2.2-cp34-none-win32.whl
    
  5. Just include in your python script:

    import curses 
    

You can use curses wrapper for python. Works in Fedora 25 in all terminals, and Windows 10 using git bash, powershell, or cmd.

Update:

  • An alternative to curses in Windows here.
  • Console user interface in Windows here.
  • An interesting tutorial here.
Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114
vgonisanz
  • 11,831
  • 13
  • 78
  • 130
  • As this question is a bit outdated ... Are there already Python 3.5 and 3.6 wheels? – Paebbels Dec 19 '16 at 17:07
  • 2
    You asked for python 3.4, I tried that version and it works. I seems doesnt exist in wheels, but exists version python 3.5 and 3.6 if you want to try. – vgonisanz Dec 19 '16 at 21:22
  • 1
    @Paebbels Yes, I checked today and there are wheels for Python 3.5 and Python 3.6 as well (and the 3.6 version works for me OK). – PhoenixS Jan 20 '17 at 11:02
  • 1
    Also, curses python works perfectly with Ubuntu app from Windows store. – vgonisanz Jul 23 '17 at 15:37
  • I get this error when trying to accomplish this Requirement 'curses-2.2-cp34-none-win32.whl' looks like a filename, but the file does not exist curses-2.2-cp34-none-win32.whl is not a supported wheel on this platform. Storing debug log for failure in /home/fishe203/.pip/pip.log whats that mean and how do i fix it? – Jade Fisher Sep 11 '18 at 16:48
  • @JadeFisher, Are you using a GNU/Linux distro? whl is only for Windows, in MAC and GNU/Linux use common ncurses packages. – vgonisanz Sep 12 '18 at 07:23
  • @vgonisanz Im using a bash shell on windows – Jade Fisher Sep 12 '18 at 15:43
  • 1
    I installed python with windows installer and tested it from cmd. I don't know if works for cygwin of similar bash shells, but if you install python using cygwin and install the whl from there, it could works. Another option (for Windows 10) is using Linux subsystem (Ubuntu, Fedora...) and GNU/Linux stuff. – vgonisanz Sep 13 '18 at 15:42
18

Now we can easy install on python 3.7 using pip install windows-curses

EmeraldDream
  • 231
  • 2
  • 3
9

You can try my mirror of unicurses, which includes pdcurses dlls. I have it currently up and running on windows 7 with python 3.5.0.

To quickly test if it works for you, just clone the repository and create and run a python script within its toplevel directory containing something like

from unicurses import *
stdscr = initscr()
addstr("hello world")
getch()
chtenb
  • 14,924
  • 14
  • 78
  • 116
  • I'll test it on my computer. – Paebbels Dec 23 '15 at 15:38
  • I'm not sure. But I wanted to fix a few things, and have a github mirror anyway. I notified the original author about the things I fixed, but I can't remember having gotten a response from that. – chtenb Nov 03 '16 at 08:21