Python curses.ascii - ModuleNotFoundError

Python curses.ascii - ModuleNotFoundError

No module named '_curses' Error

This is a common error faced by many people when they first start working with curses. We can see that curses is already installed with python without the need of any extra installation but while importing curses or any of its modules a "No module named '_curses'" error is shown. This is manly faced by windows users as in Linux curses can directly work unlike windows. If you are working in any IDE such as PyCharm etc. you will see that it shows curses package as available for import and does not mark the import statement as module not available(done for not installed modules) but when executing the code ModuleNotFoundError is thrown.

We can see below that "No module named '_curses'" is thrown while importing curses.ascii.


This happens because curses does not work directly with windows as it does for Linux. This issue can be resolved by simply installing a module named "windows-curses" which works kind of like an interface between windows and curses.

This module can be installed from cmd by using thefollowing command:

pip install windows-curses


NOTE - This command would only work if you have added python to your windows path, otherwise you would need to open cmd in directory where python is installed and then run this command.

After installing this module, we can see that curses is working normally and no error is thrown while importing curses.ascii.