How to fix Python No module named 'colors'

Problem

While running your Python application, you see the error message like this one:

example.txt
File "/app/test.py", line 9, in <module>
    from colors import red
ModuleNotFoundError: No module named 'colors'

Solution

Install the ansicolors module which provides the colors module:

example.sh
pip install ansicolors

Check out similar posts by category: Python