windows - Windows 7 上的 Python 3.4 中的 curses 需要什么?

标签 windows python-3.x curses pdcurses

我在我的 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 站点上指向 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。

有什么方法可以让 curses 在 Windows 上使用 Python 运行。

(Windows Python,而不是 CygWin Python!)

最佳答案

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

  1. 安装轮子包。如果您需要有关 wheel click here 的更多信息.

  2. 转到 this repository .

  3. 下载一个包含您的 python 版本的包,例如 python 3.4:

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

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

    import curses 
    

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

更新:

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

关于windows - Windows 7 上的 Python 3.4 中的 curses 需要什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32417379/

相关文章:

python - Curses Python 返回主菜单时不会清理窗口

java - Maven Exec 插件不在 Windows 上使用系统路径?

python - 踢掉所有命令

java - 应用程序空闲时意味着什么

python - 实际需要 global_variables_initializer() 时

python - 列表中超过 1 个最长的字符串?

Python3 - 通过网络套接字诅咒输入/输出?

调用curses包装器后Python打印困惑

windows - 如何创建可执行的命令提示符脚本

c++ - 有标准的文件保存和交换模式吗?