在Windows7上的Python 3.4中,curses需要什么?

Pae*_*els 37 windows curses pdcurses python-3.x

我在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'
Run Code Online (Sandbox Code Playgroud)

文件说:

Windows版本的Python不包含curses模块.可以使用名为UniCurses的移植版本.

因此,Python 3.4的Windows安装程序安装了具有未解析依赖项的curses.有人可以说这是一个错误......

好的,我调查了UniCurses.它是PDCurses的包装器:

UniCurses是Python 2.x/3.x的包装器,它在所有平台(MS Windows,Linux和Mac OS X)上提供统一的Curses功能集,其语法接近原始NCurses的语法.为了在Microsoft Windows系统上提供Curses功能,它包装了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
Run Code Online (Sandbox Code Playgroud)

在Python的UniCurses网站上链接到SourceForge已经死了.手动搜索SourceForge有助于再次找到UniCurses for Python.

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

我还研究了Public Domain Curses(PDCurses).PD Cureses 3.4来自2008年底.所以它已经有7年了.我不认为它适用于Windows 7,Windows 8.1或Windows 10.

有没有办法让使用Python在Windows上运行curses.

(Windows Python,而不是CygWin Python!)

vgo*_*anz 59

如果您手动安装Windows或其他包中的其他包,则可以使用curses跨平台(Windows,MacOS,GNU/Linux).

  1. 安装轮组件.如果您需要了解更多信息转盘点击这里.

  2. 转到此存储库.

  3. 下载包含python版本的软件包,例如python 3.4:

    curses-2.2-cp34-none-win_amd64.whl
    
    Run Code Online (Sandbox Code Playgroud)
  4. 安装它(如果对于windows,这个命令,在GNU/Linux安装中像其他包一样)

    python -m pip install curses-2.2-cp34-none-win32.whl
    
    Run Code Online (Sandbox Code Playgroud)
  5. 只需包含在您的python脚本中:

    import curses 
    
    Run Code Online (Sandbox Code Playgroud)

你可以使用curses包装器来实现python.适用于所有终端的Fedora 25,以及使用git bash,powershell或cmd的Windows 10.

更新:

  • 这里是Windows中curses的替代方案.
  • 在Windows控制台的用户界面这里.
  • 一个有趣的教程在这里.

  • 你问过python 3.4,我试过那个版本而且它有效.我似乎不存在轮子,但如果你想尝试,存在版本python 3.5和3.6. (2认同)

小智 13

现在我们可以轻松安装在 python 3.7 上使用 pip install windows-curses


Chi*_*nke 8

你可以尝试我的unicurses镜像,其中包括pdcurses dll.我目前在Windows 7上使用python 3.5.0运行它.

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

from unicurses import *
stdscr = initscr()
addstr("hello world")
getch()
Run Code Online (Sandbox Code Playgroud)