Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import name 'WordCloud'

I am using Jupyter Notebook and trying to build a wordcloud. Turns out there are some issues with the pillow package and the internet is full of talks around it. I was geetting the DLL error initially. I tried a lot of different things and not sure which one worked but right now, I am getting the 'cannot import name' error.

Some details from Anaconda Prompt-

>python -m pip --version
pip 18.0 from C:\Users\Kritika.Jalan\Anaconda3\lib\site-packages\pip (python 3.6)

>python -m pip install wordcloud
Requirement already satisfied: wordcloud in c:\users\kritika.jalan\anaconda3\lib\site-packages (1.5.0)
Requirement already satisfied: numpy>=1.6.1 in c:\users\kritika.jalan\anaconda3\lib\site-packages (from wordcloud) (1.15.0)
Requirement already satisfied: pillow in c:\users\kritika.jalan\anaconda3\lib\site-packages (from wordcloud) (4.0.0)
Requirement already satisfied: olefile in c:\users\kritika.jalan\anaconda3\lib\site-packages (from pillow->wordcloud) (0.45.1)

Details from Jupyter Notebook -

from wordcloud import WordCloud
ImportError: cannot import name 'WordCloud'

import PIL
print(PIL.PILLOW_VERSION)
5.0.0

What am I doing wrong here?

like image 897
Krithi07 Avatar asked Dec 04 '22 19:12

Krithi07


1 Answers

Mostly, having a can not import name error even after successful library installation, is result of conflict with your local file name and python library name.

Do you have your own python file in your local named wordcloud.py ?

If yes, that is causing conflict with wordcloud.py in python library.

Simply rename your script.

Thanks

like image 66
murat yalçın Avatar answered Dec 27 '22 01:12

murat yalçın