'wordcloud'未定义为python3.6

时间:2017-12-26 15:34:50

标签: python python-3.x

我正在尝试在此链接中制作关于电影类型的wordcloud,但我有一些错误,name 'wordcloud' is not defined即使包 已安装wordcloud

有人可以帮帮我吗,python的版本是3.6.3。

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import matplotlib.pyplot as plt
import seaborn as sns
from wordcloud import WordCloud 

# explorer les pandas series 
movies=pd.read_csv ('bit.ly/imdbratings') 

data=movies.genre.value_counts()
print(data)

plt.figure(figsize=(20,10))
wordcloud=wordcloud(background_color='white',mode="RGB", width=2000 , height=1000).generate(data)
plt.title("test")
plt.imshow(wordcloud)
plt.axis("off")
plt.show()

1 个答案:

答案 0 :(得分:2)

你必须看看你是如何导入的,你导入了什么,看看这一行:

wordcloud=wordcloud(background_color='white',mode="RGB", width=2000 , height=1000).generate(data)

应该大写

wordcloud=Wordcloud(background_color='white',mode="RGB", width=2000 , height=1000).generate(data) 

因为你导入了:

from wordcloud import WordCloud