在 Ubuntu 的 python3 上安装 NCurses

Sol*_*mon 6 python ncurses python-3.x python-curses

我在ncurses安装Python3. 当我执行正常操作时sudo apt-get install ncurses-dev,它似乎已安装,Python2但当我尝试运行我的脚本时Python3,它说。

ImportError: No module named curses
Run Code Online (Sandbox Code Playgroud)

你会怎样去ncurses工作Python3

Jos*_*hua 8

我也有同样的问题。问题是我的 Ubuntu 安装上没有安装 ncurses。为了解决这个问题,我跑了:

sudo apt-get install libncurses-dev
Run Code Online (Sandbox Code Playgroud)

然后重新安装Python。就我而言:

pyenv install 3.8.1
Run Code Online (Sandbox Code Playgroud)

当询问是否继续安装时回答 y ?(是/否)

这解决了问题。


jgr*_*tty 1

尝试这个:

import curses
Run Code Online (Sandbox Code Playgroud)

curses 是 ncurses。它也是内置于 python 中的,无需安装任何内容。

Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-65-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Last login: Mon Oct 19 19:06:03 2015 from xxx.xxx.xxx.xxx
me@ubuntu:~$ python3
Python 3.4.0 (default, Jun 19 2015, 14:20:21) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
>>> 
Run Code Online (Sandbox Code Playgroud)