2016-03-07 63 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,這是不可能很快被移植。

相關問題