ModuleNotFoundError: No module named '_curses' error is seen when running an ansible playbook. Do I need to pip install some particular module?
File "/path/python/lib/python3.7/site-packages/ansible/plugins/action/pause.py", line 41, in <module>
import curses
File "/path/python/lib/python3.7/curses/__init__.py", line 13, in <module>
from _curses import *
Another example of the error:
Python 3.7.0
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/python3/lib/python3.7/curses/__init__.py", line 13, in <module>
from _curses import *
ModuleNotFoundError: No module named '_curses'
>>>
This error is seen because curses was not installed in the system at the time of compiling Python3 sources. Therefore the solution is as follows:
First, install curses:
sudo apt-get install libncurses-dev
sudo apt-get install libncursesw5-dev
(I didn't pay attention on libncursesw5-dev and it may be redundant if libncurses-dev installs it)
Then, build Python from sources.
Python 3.7.0
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
No error now, and Ansible playbook runs!