#GovRptWordCloudv1.py
import jieba
import wordcloud
f = open("e://Users//buyin//Documents//wangzhan//py//1.txt", "r", encoding="utf-8")
t = f.read()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(width=600,height=700)
w.generate(txt)
f.close()
w.to_file("1.jpg")
>>>
============= RESTART: e:\Users\buyin\Documents\wangzhan\py\1.py =============
Building prefix dict from the default dictionary ...
Loading model from cache C:\Users\buyin\AppData\Local\Temp\jieba.cache
Loading model cost 1.821 seconds.
Prefix dict has been built succesfully.
Traceback (most recent call last):
File "e:\Users\buyin\Documents\wangzhan\py\1.py", line 9, in <module>
w = wordcloud.WordCloud(width=600,height=700)
File "C:\Users\buyin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\wordcloud\wordcloud.py", line 300, in __init__
import matplotlib
ModuleNotFoundError: No module named 'matplotlib'