| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 544 人关注过本帖
标题:大佬们救救孩子吧!实在不懂这是什么错误啊!
只看楼主 加入收藏
Utmost
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-1-2
结帖率:100%
  已结贴   问题点数:20  回复次数:4   
大佬们救救孩子吧!实在不懂这是什么错误啊!
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
fall_bernana
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:4
帖 子:97
专家分:870
注 册:2019-8-16
  得分:20 
以下是引用Utmost在2020-1-2 14:14:33的发言:

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)
>>>

看这个错误你尝试下把程序名称改成其他的名称.不要用wordcloud.py,可能是程序直接想从自身程序wordcloud.py里import WordCloud.
2020-01-02 14:21
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
zhwlyfx
Rank: 2
等 级:论坛游民
帖 子:6
专家分:34
注 册:2009-12-31
  得分:0 
学习了,这个错误提示还真没看懂
2020-01-03 23:16
快速回复:大佬们救救孩子吧!实在不懂这是什么错误啊!
数据加载中...
 
   



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

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