ImportError: No module named 'wordcloud'

Viewed 72417

I am struggling to get wordcloud installed into my environment. Here is the code I am running:

import os
import matplotlib.pyplot as plt
from wordcloud import WordCloud

I get the following error:

ImportError: No module named 'wordcloud'

I used the pip install method in my command prompt to get wordcloud into my environment. It said "requirement already satisfied". I then used the conda install -c conda-forge wordcloud method and even after doing this I continue to get the same error.

What am I doing wrong? My Python version is 3.6.2.

Image 1

Image 2

Image 3

7 Answers

first, check the python you are using with:

import sys
print(sys.executable)

then use the path it gives you and run in your jupyter terminal:

path/to/python -m pip install some_package

Which in my case is:

/anaconda3/bin/python -m pip install wordcloud

and import in your code:

from wordcloud import WordCloud

The source i used: can't import

conda install -c conda-forge wordcloud=1.6.0 

at anaconda prompt worked for me

Try using latest version of worldcloud

History: On Anaconda prompt, I installed word cloud using conda command. I was able to import, "import wordcloud", at anaconda command prompt. But it was not being imported in Spyder Ipython console, I got the following error: import wordcloud Traceback (most recent call last):

File "", line 1, in import wordcloud

ModuleNotFoundError: No module named 'wordcloud'

Solution: 1) At Ipython console write following two commands import sys print(sys.executable) we will get following output, C:\Users\mAge\Anaconda3\pythonw.exe 2) open, anaconda prompt, set its path as given above using change directory command cd 3) at anaconda prompt write: python -m pip install wordcloud 4) Screen shot showing anaconda prompt Screen shot showing Spyder Ipython console

Tip: It will also work for the scenario when "wordcloud" is not installed at our system

I had the same error, the following helped resolve (based on what @Yasi Es suggested)

In your iPython notebook, execute the following to get the path to the executable

import sys
print(sys.executable)

Take the path-to-the-executable from the above to execute the following

!<path-to-the-executable>/python -m pip install wordcloud

If you have Python 3 version then try this in terminal: pip3 install wordcloud

for python 2.7: pip install wordcloud

Try to install it using the Anaconda prompt. Open the Anaconda prompt from the start menu and use the below command.

conda install -c conda-forge wordcloud=1.8.1

Run the following command from Anaconda prompt (as administrator): conda install -c conda-forge wordcloud

Related