标题:大佬们救救孩子吧!实在不懂这是什么错误啊!
取消只看楼主
Utmost
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-1-2
结帖率:100%
已结贴  问题点数:20 回复次数:2 
大佬们救救孩子吧!实在不懂这是什么错误啊!
from wordcloud import WordCloud
m = "life is short"
w = wordcloud.WordCloud()
w.generate(m)
w.to_file("pywcloud.png")

运行结果
>>>
= RESTART: C:\Users\Administrator\AppData\Local\Programs\Python\Python38\wordcloud.py
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\wordcloud.py", line 1, in <module>
    from wordcloud import WordCloud
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\wordcloud.py", line 1, in <module>
    from wordcloud import WordCloud
ImportError: cannot import name 'WordCloud' from partially initialized module 'wordcloud' (most likely due to a circular import) (C:\Users\Administrator\AppData\Local\Programs\Python\Python38\wordcloud.py)
>>>
搜索更多相关主题的帖子: Python import Users from Local 
2020-01-02 14:14
Utmost
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-1-2
得分:0 
回复 2楼 fall_bernana
import wordcloud
txt = "life is short"
w = wordcloud.WordCloud(background_color="white")
w.generate(txt)
w.to_file("pywcloud.png")

结果:
>>>
= RESTART: C:\Users\Administrator\AppData\Local\Programs\Python\Python38\bbb.py.py
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\bbb.py.py", line 1, in <module>
    import wordcloud
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\wordcloud.py", line 1, in <module>
    from wordcloud import WordCloud
ImportError: cannot import name 'WordCloud' from partially initialized module 'wordcloud' (most likely due to a circular import) (C:\Users\Administrator\AppData\Local\Programs\Python\Python38\wordcloud.py)
>>>

还是不行啊!
2020-01-02 14:33
Utmost
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-1-2
得分:0 
回复 3楼 Utmost
大佬你启发了我,莫名其妙的我还有一个叫wordcloud的,我删了之后就成功了!
2020-01-02 14:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-498779-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.282731 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved