Python 导入错误:尝试导入祝福时没有名为“_curses”的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35850362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ImportError: No module named '_curses' when trying to import blessings
提问by Nazarii Morhun
I am trying to run this:
我正在尝试运行这个:
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.')
Which is the first example here: https://pypi.python.org/pypi/blessings.
这是这里的第一个示例:https: //pypi.python.org/pypi/blessings。
However, I get this error:
但是,我收到此错误:
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'
My system is win10 x64.
我的系统是win10 x64。
回答by Bruno Ranieri
Meanwhile - Python 2.7.15 on Windows 10 - curses support can be added by:
同时 - Windows 10 上的 Python 2.7.15 - 可以通过以下方式添加诅咒支持:
pip install windows-curses
回答by Forge
The curses
module is not supported on Windows
machines. From the module documentation:
机器curses
不支持该模块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.
虽然curses 在Unix 环境中使用最为广泛,但也有适用于DOS、OS/2 和其他系统的版本。该扩展模块旨在匹配 ncurses 的 API,这是一个托管在 Linux 上的开源 Curses 库和 Unix 的 BSD 变体。
Install the unofficial windows binary for curses
from hereand try again.
curses
从这里安装非官方的 Windows 二进制文件,然后重试。
回答by Niklas Holm
回答by Sreegovind S V
First Install curses using pip like this Open Command Prompt
首先像这样打开命令提示符使用pip安装curses
type "pip install windows-curses"(This Only works if pip is installed in environmental variables)
输入“pip install windows-curses”(仅当pip安装在环境变量中时才有效)
If running curses doesn't work using Pycharm, Try other Interpreters Apps like Atom, Visual Studios, and if that does not work, Install Python in Environmental Variables(Links will be at the bottom). Then Launch CMD or Command Prompt and type "python (the root of .py file)" (eg. python C:\Users\user\Plane.py) and then press enter.
如果使用 Pycharm 运行 curses 不起作用,请尝试其他解释器应用程序,如 Atom、Visual Studios,如果不起作用,请在环境变量中安装 Python(链接将在底部)。然后启动 CMD 或命令提示符并键入“python(.py 文件的根目录)”(例如 python C:\Users\user\Plane.py),然后按 Enter。
Link for installing Python in Environmental Variables - https://www.youtube.com/watch?v=1jyOHCTgWpg
在环境变量中安装 Python 的链接 - https://www.youtube.com/watch?v=1jyOHCTgWpg