python wordcloud库使用过程中的问题1

2021-07-01 17:04

阅读:450

标签:http   ams   tps   not   dcl   wordcloud   init   .net   otf   

首先创建了一个简单的py项目;

#wordcloud.py
import wordcloud
c=wordcloud.WordCloud()
c.generate("wordcloud by python")
c.to_file("pyworldcloud.png")

编译报错:

Traceback (most recent call last):
  File "E:/1/python/file/wordcloud.py", line 7, in import wordcloud
  File "E:/1/python/file\wordcloud.py", line 9, in 
    w=wordcloud.WordCloud(AttributeError: module wordcloud has no attribute WordCloud
>>> 

——解决办法CSDN:

https://blog.csdn.net/BeautyJingJing/article/details/80306731

文件名不可与wordcloud相同,将文件名改为

#wcloud1.py

 

运行编译,出现错误提示:

Traceback (most recent call last):
  File "E:/1/python/file/wcloud1.py", line 3, in 
    c=wordcloud.WordCloud()
  File "C:\Users\26408\AppData\Local\Programs\Python\Python37\lib\site-packages\wordcloud\wordcloud.py", line 300, in __init__
    import matplotlib
ModuleNotFoundError: No module named matplotlib
>>> 

估计为为安装第三方库matplotlib;

——解决方法CSDN:

https://blog.csdn.net/dongyanwen6036/article/details/78290878

在cmd下安装第三方库:

D:\myLib>pip install wordcloud

编译运行,打开项目所在文件夹:

出现图片:

pyworldcloud.png

技术分享图片

完成;

python wordcloud库使用过程中的问题1

标签:http   ams   tps   not   dcl   wordcloud   init   .net   otf   

原文地址:https://www.cnblogs.com/liuxiaoqian17/p/9637159.html


评论


亲,登录后才可以留言!