Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install NCurses on python3 for Ubuntu

I'm having issues installing ncurses for Python3. When I did the normal sudo apt-get install ncurses-dev, it appeared to install for Python2 but when I try to run my script for Python3, it says.

ImportError: No module named curses

How would you get ncurses to work for Python3?

like image 259
Solomon Avatar asked Jul 19 '26 08:07

Solomon


2 Answers

I had this same problem. The issue was that ncurses was not installed on my Ubuntu installation. To fix it, I ran:

sudo apt-get install libncurses-dev

and then reinstalled Python. In my case with:

pyenv install 3.8.1

Answering y when asked continue with installation? (y/N)

This fixed the problem.

like image 183
Joshua Avatar answered Jul 21 '26 23:07

Joshua


Try this:

import curses

curses is ncurses. It's also built in to python, there's nothing to install.

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
>>> 
like image 24
jgritty Avatar answered Jul 21 '26 23:07

jgritty