当前位置: 代码迷 >> python >> 在 python3 上为 Ubuntu 安装 NCurses
  详细解决方案

在 python3 上为 Ubuntu 安装 NCurses

热度:154   发布时间:2023-06-13 15:13:56.0

我在为Python3安装ncurses遇到问题。 当我执行正常的sudo apt-get install ncurses-dev ,它似乎是为Python2安装的,但是当我尝试为Python3运行我的脚本Python3 ,它说。

ImportError: No module named curses

你如何让ncursesPython3工作?

尝试这个:

import 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
>>> 

我有同样的问题。 问题是我的 Ubuntu 安装中没有安装 ncurses。 为了修复它,我跑了:

sudo apt-get install libncurses-dev

然后重新安装Python。 在我的情况下:

pyenv install 3.8.1

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

这解决了问题。