38

I am trying to run this:

from blessings import Terminal

t = Terminal()

print (t.bold('Hi there!'))
print (t.bold_red_on_bright_green('It hurts my eyes!'))

with t.location(0, t.height - 1):
    print ('This is at the bottom.')

Which is the first example here: https://pypi.python.org/pypi/blessings.

However, I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\�����\AppData\Local\Programs\Python\Python35-     32\lib\site-packages\blessings\__init__.py", line 5, in <module>
    import curses
  File "C:\Users\�����\AppData\Local\Programs\Python\Python35-32\lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ImportError: No module named '_curses'

My system is win10 x64.

Forge
  • 6,538
  • 6
  • 44
  • 64
Nazarii Morhun
  • 489
  • 1
  • 4
  • 3
  • 4
    Try this [curses](http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses) implementation for Windows. – Eryk Sun Mar 07 '16 at 19:39
  • I have the same exact problem on Windows 7 and am looking for a workaround. The part in the readme that mentions `colorama` for usage on Windows would imply that the library works on Windows somehow. I'm a bit new to Python so I am not sure if wrapping the import statement in a try/except construct would be a valid approach, but I am looking into it. Also, FYI, can confirm that the fork of `blessings` called `blessed` has the same problem (v1.6). – Adam P Jan 23 '17 at 21:34
  • @AdamP update, the readme for the [`blessed`](https://github.com/jquast/blessed) module has a slightly different statement than that for the blessings module which does clearly indicate that the module does not work on Windows command prompt: "Blessed does not provide... Windows command prompt support. A PDCurses build of python for windows provides only partial support at this time -- there are plans to merge with the ansi module in concert with colorama to resolve this. Patches welcome!" – Adam P Jan 23 '17 at 21:52
  • @eryksun How do you get that implementation to run? – SirJames Feb 17 '17 at 14:38
  • Do you mean how to install the wheel package? Use `pip install curses‑2.2‑cp35‑none‑win32.whl` or whatever the filename is for the wheel you're trying to install. – Eryk Sun Feb 17 '17 at 14:44

5 Answers5

52

Meanwhile - Python 2.7.15 on Windows 10 - curses support can be added by:

pip install windows-curses
Bruno Ranieri
  • 655
  • 6
  • 9
15

The curses module is not supported on Windows machines. From the module documentation:

While curses is most widely used in the Unix environment, versions are available for DOS, OS/2, and possibly other systems as well. This extension module is designed to match the API of ncurses, an open-source curses library hosted on Linux and the BSD variants of Unix.

Install the unofficial windows binary for curses from here and try again.

Forge
  • 6,538
  • 6
  • 44
  • 64
9

All you need is just download the library

pip install windows-curses
3

It's a known bug on windows. It has been open for 5 years, so don't hold your breath.

The unofficial curses build is not enough since it also requires fcntl, which isn't likely to be ported anytime soon.

Niklas Holm
  • 949
  • 9
  • 14
1

First Install curses using pip like this Open Command Prompt

type "pip install windows-curses"(This Only works if pip is installed in environmental variables)

If running curses doesn't work using Pycharm, Try other Interpreters Apps like Atom, Visual Studios, and if that does not work, Install Python in Environmental Variables(Links will be at the bottom). Then Launch CMD or Command Prompt and type "python (the root of .py file)" (eg. python C:\Users\user\Plane.py) and then press enter.

Link for installing Python in Environmental Variables - https://www.youtube.com/watch?v=1jyOHCTgWpg