Windows7 Python 3.4 中的 curses 需要什么?

What is needed for curses in Python 3.4 on Windows7?

我在 Windows 7 (x64) 机器上安装了 运行 Python 2.7/3.4。我想在 Windows.

上测试 curses

Curses 已安装但无法运行:

>>> 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'

documentation 说:

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

因此,Python 3.4 的 Windows 安装程序安装了 curses,但依赖项未解决。人们可以将其命名为错误...

好的,我研究了 UniCurses。它是 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.

通过 pip3 安装 UniCurses 导致错误:

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

Python 的 UniCurses 站点上的 link 到 SourceForge 已经死了。手动搜索 SourceForge 帮助再次找到 UniCurses for Python

但是,UniCurses 1.2 安装程序无法在我的 Windows 注册表中找到任何 Python 安装。 (Python 2.7.9 和 Python 3.4.2 可用)。

我还研究了 Public 领域诅咒 (PDCurses)。 PD Cureses 3.4 是从 2008 年底开始的。所以它已经 7 岁了。我不相信它会与 Windows 7 或 Windows 8.1 或 Windows 10.

一起使用

有什么方法可以用 Python.

在 Windows 上得到诅咒 运行

(Windows Python,不是 CygWin Python!)

您可以尝试 my mirror of unicurses,其中包括 pdcurses dll。我目前正在使用 运行ning windows 7 python 3.5.0.

要快速测试它是否适合您,只需克隆存储库并在其顶层目录中创建 运行 一个 python 脚本,其中包含类似

的内容
from unicurses import *
stdscr = initscr()
addstr("hello world")
getch()

如果您为 Windows 手动安装或喜欢其他包中的其他软件包,则可以跨平台使用 curses(Windows、MacOS、GNU/Linux)。

  1. 安装 wheel 包。如果您需要有关 wheel click here.

  2. 的更多信息
  3. 转到this repository

  4. 使用您的 python 版本下载一个包,例如 python 3.4:

    curses-2.2-cp34-none-win_amd64.whl
    
  5. 安装它(此命令如果用于 windows,在 GNU/Linux 中像其他包一样安装)

    python -m pip install curses-2.2-cp34-none-win32.whl
    
  6. 只需在您的 python 脚本中包含:

    import curses 
    

您可以为 python 使用 curses 包装器。在所有终端的 Fedora 25 中工作,在 Windows 10 中使用 git bash、powershell 或 cmd。

更新:

  • Windows here.
  • 中 curses 的替代方法
  • Windows here.
  • 中的控制台用户界面
  • 一个有趣的教程here

现在我们可以使用 pip install windows-curses

在 python 3.7 上轻松安装