Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named 'termcolor'

Tags:

python

No module named 'termcolor'

pip install termcolor returns

C:\Users\admin>pip install termcolor
Requirement already satisfied: termcolor in c:\python27\lib\site-packages
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Not sure why I can't import this module? Here's the code.

from termcolor import colored
like image 419
Lee Nelson Avatar asked Jul 26 '18 03:07

Lee Nelson


People also ask

How do I fix No module named termcolor?

The Python "ModuleNotFoundError: No module named 'termcolor'" occurs when we forget to install the termcolor module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install termcolor command.

How do I install termcolor in Python?

Type "cmd" in the search bar and hit Enter to open the command line. What is this? Type “ pip install termcolor ” (without quotes) in the command line and hit Enter again. This installs termcolor for your default Python installation.


1 Answers

My guess is that you probably have two versions of Python or downloaded the wrong module.

1)Wrong Module:

pip install term color

It will install a different module. To fix it, install the correct module:

pip install termcolor

2)Two-Versions

If you have two versions of Python, you need to specify it:

i)Two versions of Python 3:

If you two versions of Python3, specify:

pip3.x install termcolor

ii)If you have Python 2 installed:

If you have Python 2 and 3 installed, specify it, as pip works for Python2, and pip3 works for Python 3:

pip3 install termcolor

If you have only Python3, or in simple words only one version of Python, You can follow the first instruction.

like image 74
Mahir Islam Avatar answered Oct 31 '22 11:10

Mahir Islam