Windows下,ImportError: The _imagingft C module is not installed问题解决

本文讲述了在使用WordCloud时遇到的Pillow包问题,通过StackOverflow找到的解决方案,包括卸载并重新安装Pillow,加上--no-cache-dir选项,并着重介绍了成功安装freetype-py模块的方法,确保了WordCloud的正确运行。
摘要由CSDN通过智能技术生成

使用WordCloud包报了如下错误,很明显问题在pillow包上
网上搜了很多法子都解决不了,最后去国外的StackOverflow上找到了解决方法(https://stackoverflow.com/questions/74178079/wordcloud-installation-on-windows-pil-pillow

Traceback (most recent call last):
  File "D:\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3457, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-14-a5239e150765>", line 1, in <module>
    wordcloud=wordcloud.generate(text)
  File "D:\anaconda3\lib\site-packages\wordcloud\wordcloud.py", line 639, in generate
    return self.generate_from_text(text)
  File "D:\anaconda3\lib\site-packages\wordcloud\wordcloud.py", line 621, in generate_from_text
    self.generate_from_frequencies(words)
  File "D:\anaconda3\lib\site-packages\wordcloud\wordcloud.py", line 453, in generate_from_frequencies
    self.generate_from_frequencies(dict(frequencies[:2]),
  File "D:\anaconda3\lib\site-packages\wordcloud\wordcloud.py", line 503, in generate_from_frequencies
    font = ImageFont.truetype(self.font_path, font_size)
  File "D:\anaconda3\lib\site-packages\PIL\ImageFont.py", line 959, in truetype
    return freetype(font)
  File "D:\anaconda3\lib\site-packages\PIL\ImageFont.py", line 956, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "D:\anaconda3\lib\site-packages\PIL\ImageFont.py", line 219, in __init__
    if core.HAVE_RAQM:
  File "D:\anaconda3\lib\site-packages\PIL\ImageFont.py", line 58, in __getattr__
    raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed

解决方法:

pip install freetype-py

pip uninstall pillow
pip install --no-cache-dir pillow

成功解决!
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值