其他分享
首页 > 其他分享> > 做词云时报错cannot import name ‘WordCloud‘ from partially initialized module ‘wordcloud‘的解决办法

做词云时报错cannot import name ‘WordCloud‘ from partially initialized module ‘wordcloud‘的解决办法

作者:互联网

问题:

在做词云时,运行时出现该问题,wordcloud安装成功,但运行出错,错误提示是:cannot import name ‘WordCloud’ from partially initialized module ‘wordcloud’ (most likely due to a circular import)
在这里插入图片描述

错误提示代码:

Traceback (most recent call last):
  File "D:\mypythonprograms\wordcloud\wordcloud.py", line 4, in <module>
    import wordcloud #分词
  File "D:\mypythonprograms\wordcloud\wordcloud.py", line 5, in <module>
    from wordcloud import WordCloud,ImageColorGenerator,STOPWORDS #词云,颜色生成器,停止
ImportError: cannot import name 'WordCloud' from partially initialized module 'wordcloud' (most likely due to a circular import) (D:\mypythonprograms\wordcloud\wordcloud.py)

Process finished with exit code 1

 

解决方法:

文件名不能取"wordcloud.py" ,重命名后运行成功!

重命名:
在这里插入图片描述
在这里插入图片描述
运行成功:
在这里插入图片描述
在这里插入图片描述

 

标签:mypythonprograms,py,WordCloud,module,wordcloud,import
来源: https://www.cnblogs.com/ay2021/p/15023776.html