2016-03-07 65 views
11

我试图运行这段代码时:导入错误:没有名为模块“_curses”试图导入祝福

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 64。

+1

尝试为Windows这个[诅咒](http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses)执行。 – eryksun

+0

我在Windows 7上遇到了同样的问题,并且正在寻找解决方法。在自述文件中提到“colorama”用于Windows的部分意味着该库以某种方式在Windows上工作。我对Python有点新,所以我不确定在try/except构造中包装import语句是否是一种有效的方法,但我正在研究它。此外,FYI可以确认称为'祝福'的'祝福'的叉具有同样的问题(v1.6)。 –

+0

@AdamP更新,['祝福'](https://github.com/jquast/blessed)模块的自述文件与明确表示模块无法工作的祝福模块的语句略有不同Windows命令提示符: “Blessed不提供... Windows命令提示符支持。python for windows的python for python目前仅提供部分支持 - 有计划将ansi模块与colorama合并以解决问题这个,补丁欢迎!“ –

回答

8

模块在Windows机器上不受支持。从模块文档:

While curses is most widely used in the Unix environment, versions are available for DOS, OS/2, and possibly other systems as well. This extension module is designed to match the API of ncurses, an open-source curses library hosted on Linux and the BSD variants of Unix.

here安装了curses非官方窗口二进制,然后再试一次。

+0

这是否意味着我不能在窗口上使用祝福库? –

0

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

非正式的curses构建是不够的,因为它也需要fcntl,这是不可能很快被移植。

相关问题