Installing wordcloud using Jupyter Notebook
Asked Answered
U

12

10

I need to solve a wordcloud problem for a homework assignment.

Unfortunately, I am having a hard time getting 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'

Now, I know I need to use the pip install method in my command prompt to get wordcloud into my environment. Even after doing this (and trying several different destinations, including my home directory and the Anaconda3 environment), I continue to get the same error.

What am I doing wrong?

Ululate answered 22/1, 2017 at 15:3 Comment(1)
What operating system are you running it on? What version of Python?Cchaddie
M
16

Try

python -m pip install wordcloud

You probably need numpy and pillow as well.

Mcallister answered 22/1, 2017 at 15:11 Comment(3)
I tried that, and I'm still getting the same error. Is the problem that I'm installing it into the wrong file path???Ululate
Now its "Python3"Micturition
Inside Jupyter notebook, try -> !pip install wordcloudTopographer
D
12

Try this on Jupyter cell:

!pip install wordcloud
Douglasdouglashome answered 2/6, 2020 at 13:6 Comment(0)
B
7

this solution solved my problem which was because of different pythons on my system.

in Jupyter, run:

import sys
print(sys.executable)

to see which python you are using. copy the pass and install the wordcloud with this command from your Jupiter 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

Belemnite answered 9/12, 2018 at 20:0 Comment(0)
M
2

Try installing using conda after activating the environment that contains numpy and pillow. Make sure your code is running in that environment.

conda install -c conda-forge wordcloud=1.2.1

Other sources available on anaconda

Microcline answered 22/1, 2017 at 15:34 Comment(1)
Still not working for me. Is this to be written on the command prompt or in the jupyter notebook?Ratiocination
G
2

open anaconda prompt and enter

python -m pip install wordcloud
Gennygeno answered 28/12, 2018 at 15:31 Comment(0)
M
0

I am hoping that you might be using MAC. In that case, check if word cloud got installed in the same place where conda is.

In my case, running it on python3 was working fine but running it on Anaconda was giving an import error.

These are steps that I followed to resolve the issue:

  1. Open the conda terminal from the application. If you are having problems (such as process completed) check whether you are using bash or zsh. Currently conda terminal is supported only on bash. You can change the default shell using the below commands:

Use: chsh -s /bin/bash to change the shell from zsh to bash.

Use: chsh -s /bin/zsh to revert back to zsh later.

  1. Once changed to bash, install word cloud for anaconda using the below command:

conda install -c conda-forge wordcloud

Voila! Your imports should work now, just as mine did.

Mallard answered 2/5, 2018 at 7:7 Comment(2)
"check whether you are using bash or zsh" how do I do this?Ratiocination
You could do this in multiple ways - echo $0, echo $SHELL ( You can refer to the answer - #9911466)Mallard
S
0

I had the same issue, had to make a new conda environment and then installed it. (https://conda.io/docs/user-guide/getting-started.html)

"1.Create a new environment and install a package in it. We will name the environment snowflakes and install the package wordcloud. At the Anaconda Prompt or in your Terminal window, type the following:"

conda create --name snowflakes wordcloud
Stibine answered 14/1, 2019 at 19:54 Comment(0)
C
0

to install wordcloud - execute "pip install wordcloud" from Anaconda prompt (not cmd)

Clarissa answered 26/6, 2019 at 19:55 Comment(0)
C
0

After installing wordcloud using pip python -m pip install wordcloud, its working fine in jupyter Notebook.

pip install wordcloud

Connell answered 21/7, 2019 at 1:50 Comment(0)
S
0

open anaconda prompt and enter

pip install wordcloud

Then go to jupyter and write

from wordcloud import WordCloud
Sherer answered 17/9, 2019 at 12:43 Comment(0)
G
0

As you are using Jupyter Notebook. Try using following these commands in Anaconda prompt. It will work fine.

conda install -c conda-forge wordcloud
conda install -c conda-forge/label/gcc7 wordcloud
conda install -c conda-forge/label/cf201901 wordcloud
conda install -c conda-forge/label/cf202003 wordcloud
Gentianella answered 16/4, 2021 at 15:27 Comment(0)
W
-1

Before install libpython3-dev

$ sudo apt-get install libpython3-dev
$ sudo pip install wordcloud
Whimsicality answered 3/6, 2018 at 18:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.