Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'wordcloud'

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

like image 881
Blg Khalil Avatar asked Nov 15 '17 01:11

Blg Khalil


4 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

like image 118
Yasi Klingler Avatar answered Nov 12 '22 06:11

Yasi Klingler


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
like image 21
user3119935 Avatar answered Nov 12 '22 05:11

user3119935


conda install -c conda-forge wordcloud=1.6.0 

at anaconda prompt worked for me

Try using latest version of worldcloud

like image 5
Arthur Avatar answered Nov 12 '22 05:11

Arthur


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

like image 4
mAge Avatar answered Nov 12 '22 05:11

mAge