ModuleNotFoundError: No module named '_curses' on Ubuntu 22.04

Question:

I want to use curses for a personnal Python project. However, when I try to import it, I get the following error :

>>> import curses
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xxxxxx/.asdf/installs/python/3.9.13/lib/python3.9/curses/__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'

I know this is an identified bug on windows, solved through the installation of windows-curses, however I can’t solve the problem on my Ubuntu machine. Here are all the curses-related packages currently installed on the machine :

> apt search --installed curses
libncurses-dev 6.3-2 [Ubuntu/jammy main]
├── is installed
└── developer's libraries for ncurses

libncurses6 6.3-2 [Ubuntu/jammy main]
├── is installed
└── shared libraries for terminal handling

libncursesw5-dev 6.3-2 [Ubuntu/jammy main]
├── is installed
└── transitional package for libncurses-dev

libncursesw6 6.3-2 [Ubuntu/jammy main]
├── is installed
└── shared libraries for terminal handling (wide character support)

libtinfo6 6.3-2 [Ubuntu/jammy main]
├── is installed
└── shared low-level terminfo library for terminal handling

ncurses-base 6.3-2 [Ubuntu/jammy main]
├── is installed
└── basic terminal type definitions

ncurses-bin 6.3-2 [Ubuntu/jammy main]
├── is installed
└── terminal-related programs and man pages

pinentry-curses 1.1.1-1build2 [Ubuntu/jammy main]
├── is installed
└── curses-based PIN or pass-phrase entry dialog for GnuPG

Any idea ?

Asked By: Kahsius

||

Answers:

It appears that python 3.9.13 can’t import curses. Using python 3.8.1 or 3.9.14 solved the problem.

EDIT : Add another python version supporting curses

Answered By: Kahsius