I was looking up on how to write a (relatively) friendly user interface in Python for a program of mine, and as I understood I need a module called "curses". I tried to install it via the pip method, but the shell says that no matching distibution have been found for the specified module. Am I doing something wrong or what? Has the module been taken down for some reason? If so, how else can I write such an interface, given that I just need to make the arrow keys work for my program? Thanks in advance
Asked
Active
Viewed 308 times
-1
-
3Are you trying to write a Windows program using `curses`? If so, from the [**official documentation**](https://docs.python.org/3/howto/curses.html#what-is-curses): `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.` – zwer Sep 23 '18 at 18:09
-
Ok, so you mean I can't actually use it. Great. The Console module is written for python 2x only, I'll try to use unicurses then. – Michele Bastione Sep 23 '18 at 18:38
-
I suggest using PyQt5 Module. It's an outstanding module for building GUI – Seungho Lee Sep 23 '18 at 19:31
-
@MattLee I'd suggest using IPython to develop GUIs [interactively](https://ipython.readthedocs.io/en/stable/config/eventloops.html), even if you only use tkinter. It does support `qt` though, and `wx` and `gtk` too. – gilch Sep 25 '18 at 01:31
1 Answers
0
Curses is in the standard library. Just import it.
If you're on Windows, you can try installing the unofficial wheel (with pip install foo.whl
where foo
is the name of the wheel file--download the one that matches your Python installation).
Here's an example install for Python 2.7 64-bit.
C:\>py -2 -m pip install curses-2.2-cp27-cp27m-win_amd64.whl
Here's a simple curses "hello world" to test it.
import curses
@curses.wrapper
def main(stdscr):
stdscr.clear()
stdscr.addstr(5, 20, 'hello world')
stdscr.getch()
Save to a file like cursestest.py
then run it like
C:\>py -2 cursestest.py
I tested the above on my Windows machine, and it works fine.

gilch
- 10,813
- 1
- 23
- 28
-
-
@MicheleBastione so you are on Windows. Did you try installing the wheel first? – gilch Sep 23 '18 at 18:40
-
-
Ok, it's been installed, and I can go as far as to import the module, but apparently none of the functions from the official documentation work. What do I do? – Michele Bastione Sep 23 '18 at 19:15
-
@MicheleBastione Make certain that the wheel you install matches the Python version you are using (Version number like 2.7 and 32 or 64 bit.) And install with the pip running on that Python. Try the "hello world" script above. – gilch Sep 25 '18 at 01:21
-