What is needed for curses in Python 3.4 on Windows7?

70,930

Solution 1

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.

Solution 2

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

Solution 3

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()
Share:
70,930
Paebbels
Author by

Paebbels

Patrick Lehmann studied computer science at Technische Universität Dresden, Germany. His professional career already found its foundation here when he was already teaching as a tutor computer engineering and computer architecture Later on, he specialized in digital design, FPGA technology, and high-speed communication solutions like Serial-ATA, Gigabit Ethernet, or PCI Express. He was sharing his gained knowledge in labs, research articles, and on social platforms. The focus of his research work is was on in-memory database systems, the Serial-ATA protocol implementation, and embedding FPGAs into a Cloud infrastructure. Since 2017, Patrick Lehmann is working for PLC2 GmbH as a instructor in the topics of VHDL, OSVVM, FPGA technology as well as high-speed communication. As a consultant and “fire fighter” he helps critical projects to bring on track. In cooperation with PLC2 Design GmbH, he is a senior system architect for FPGA-based solutions, team leader in FPGA design projects, and technical project advisor. Mr. Lehmann is one of the developers and maintainers of the PoC-Library, a platform and vendor independent open source IP core library. He is a contributor to the GHDL project as well, a free VHDL simulator and synthesis tool. In 2016, he started an initiative called "Open Source VHDL Group", whose aim is a free collection of VHDL packages. As a maintainer of more than 40 open source repositories and owner of several GitHub organizations, he is one of circa 20 people worldwide driving the open source community for EDA related tooling. Furthermore, Mr. Lehmann is very active in the IEEE P1076 "VHDL Analysis and Standardization Group" since 2014. He detailed and wrote major parts of the language changes for the current VHDL-2019 revision. In 2017, he became an IEEE Standards Association member and was announced vice-chair of the IEEE P1076 working group. He managed to register VHDL as an open source pilot project. In cooperation with IEEE SA, the working group successfully publishes all VHDL language packages as the first open-source standard in the history of IEEE. In 2021, the IEEE P1076 working group for VHDL-2025 was approved. One of its main goals is to create a new collaborative and open-source publishing flow at IEEE SA, so the whole standard might become open source.

Updated on July 09, 2022

Comments

  • Paebbels
    Paebbels almost 2 years

    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
    Paebbels over 8 years
    I'll test it on my computer.
  • chtenb
    chtenb over 7 years
    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.
  • Paebbels
    Paebbels over 7 years
    As this question is a bit outdated ... Are there already Python 3.5 and 3.6 wheels?
  • vgonisanz
    vgonisanz over 7 years
    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.
  • PhoenixS
    PhoenixS over 7 years
    @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).
  • vgonisanz
    vgonisanz almost 7 years
    Also, curses python works perfectly with Ubuntu app from Windows store.
  • Jade Fisher
    Jade Fisher almost 6 years
    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?
  • vgonisanz
    vgonisanz almost 6 years
    @JadeFisher, Are you using a GNU/Linux distro? whl is only for Windows, in MAC and GNU/Linux use common ncurses packages.
  • Jade Fisher
    Jade Fisher almost 6 years
    @vgonisanz Im using a bash shell on windows
  • vgonisanz
    vgonisanz almost 6 years
    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.