导入错误:尝试导入祝福时没有名为“_curses”的模块

问题描述 投票:0回答:6

我正在尝试运行这个:

from blessings import Terminal

t = Terminal()

print (t.bold('Hi there!'))
print (t.bold_red_on_bright_green('It hurts my eyes!'))

with t.location(0, t.height - 1):
    print ('This is at the bottom.')

这是这里的第一个示例:https://pypi.python.org/pypi/blessings

但是,我收到此错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\�����\AppData\Local\Programs\Python\Python35-     32\lib\site-packages\blessings\__init__.py", line 5, in <module>
    import curses
  File "C:\Users\�����\AppData\Local\Programs\Python\Python35-32\lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ImportError: No module named '_curses'

我的系统是win10 x64。

python windows module curses python-curses
6个回答
54
投票

同时 - Windows 10 上的 Python 2.7.15 - 可以通过以下方式添加诅咒支持:

pip install windows-curses

14
投票

curses

 机器不支持 
Windows
 模块。来自模块文档:

虽然curses在Unix环境中使用最广泛,但版本不同 适用于 DOS、OS/2,也可能适用于其他系统。这 扩展模块旨在匹配 ncurses 的 API, 托管在 Linux 和 BSD 变体上的开源 Curses 库 Unix。

这里
安装curses的非官方Windows二进制文件,然后重试。


9
投票

您只需下载库即可

pip install windows-curses

3
投票

这是 Windows 上的一个已知错误。它已经开业5年了,所以不要屏住呼吸。

非官方的

curses
构建还不够,因为它还需要
fcntl
,而它不太可能很快被移植。


1
投票

首先像这样使用pip安装curses 打开命令提示符

输入“pip install windows-curses”(仅当 pip 安装在环境变量中时才有效)

如果使用Pycharm运行curses不起作用,请尝试其他解释器应用程序,如Atom、Visual Studios,如果不起作用,请在环境变量中安装Python(链接将在底部)。然后启动 CMD 或命令提示符并输入“python(.py 文件的根目录)” (例如 python C:\Users\user\Plane.py),然后按 Enter。

在环境变量中安装 Python 的链接 - https://www.youtube.com/watch?v=1jyOHCTgWpg


0
投票

您可以尝试

blessed
(https://pypi.org/project/blessed/),它是
blessings
的分支并支持 Windows。

© www.soinside.com 2019 - 2024. All rights reserved.