做词云时报错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)
做词云时报错cannot import name ‘WordCloud‘ from partially initialized module ‘wordcloud‘的解决办法

错误提示代码:

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" ,重命名后运行成功!

重命名:
做词云时报错cannot import name ‘WordCloud‘ from partially initialized module ‘wordcloud‘的解决办法
做词云时报错cannot import name ‘WordCloud‘ from partially initialized module ‘wordcloud‘的解决办法
运行成功:
做词云时报错cannot import name ‘WordCloud‘ from partially initialized module ‘wordcloud‘的解决办法
做词云时报错cannot import name ‘WordCloud‘ from partially initialized module ‘wordcloud‘的解决办法

 

上一篇:python 中关于词云wordcloud的一些总结:


下一篇:WordCloud:连份好点的词云资料都找不到?我什么时候受过这气!!!