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?
Try
python -m pip install wordcloud
You probably need numpy
and pillow
as well.
在 Jupyter 单元上试试这个:
!pip install wordcloud
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
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
打开 anaconda prompt 并输入
python -m pip install wordcloud
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:
Use: chsh -s /bin/bash to change the shell from zsh to bash.
Use: chsh -s /bin/zsh to revert back to zsh later.
conda install -c conda-forge wordcloud
Voila! Your imports should work now, just as mine did.
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
安装 wordcloud - 从 Anaconda 提示符(不是 cmd)执行“pip install wordcloud”
After installing wordcloud using pip python -m pip install wordcloud
, its working fine in jupyter Notebook.
open anaconda prompt and enter
pip install wordcloud
Then go to jupyter and write
from wordcloud import WordCloud
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
Before install libpython3-dev
$ sudo apt-get install libpython3-dev
$ sudo pip install wordcloud
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.