当前位置:   article > 正文

python使用wordcloud时出现以下错误,如何解决_return self.generate_from_text(text)

return self.generate_from_text(text)
代码:import wordcloud
          w=wordcloud.WordCloud(background_color="write")
          txt='life is short,you need python'
          w.generate(txt)

          w.to_file("wordtest.png")

运行结果:Traceback (most recent call last):
  File "D:\python练习文件\wordtest.py", line 6, in <module>
    w.generate(txt)
  File "D:\软件安装\python\lib\site-packages\wordcloud\wordcloud.py", line 571, in generate
    return self.generate_from_text(text)
  File "D:\软件安装\python\lib\site-packages\wordcloud\wordcloud.py", line 553, in generate_from_text
    self.generate_from_frequencies(words)
  File "D:\软件安装\python\lib\site-packages\wordcloud\wordcloud.py", line 405, in generate_from_frequencies
    max_font_size=self.height)
  File "D:\软件安装\python\lib\site-packages\wordcloud\wordcloud.py", line 439, in generate_from_frequencies
    font = ImageFont.truetype(self.font_path, font_size)
  File "D:\软件安装\python\lib\site-packages\PIL\ImageFont.py", line 261, in truetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "D:\软件安装\python\lib\site-packages\PIL\ImageFont.py", line 144, in __init__
    self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine)
OSError: cannot open resource

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/531992
推荐阅读
相关标签
  

闽ICP备14008679号