AttributeError: module ‘PIL.Image‘ has no attribute ‘Resampling‘报错解决

文章讲述了在使用easyocr进行中文和英文图片文字识别时遇到的AttributeError,特别是在导入PIL.Image模块时。作者尝试了网上找到的解决方法,包括引入特定的图像处理包和更新Pillow,但问题仍未解决。最后通过添加`--user`选项成功更新了Pillow库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

AttributeError: module 'PIL.Image' has no attribute 'Resampling':

该问题出现在利用easyocr的时候,准备进行图片中文字的识别。

import easyocr
reader = easyocr.Reader(['ch_tra','en'])
result = reader.readtext(r'D:\aaa\try.png')
print(result)

发现出现该报错,一开始在网上找的解决办法针对到具体的包的内容进行的引用,

from PIL import Image

try:
    from PIL import ImageFilter, ImageOps, ImageEnhance, __version__, UnidentifiedImageError
    from PIL.Image import BICUBIC, LANCZOS, NEAREST, BILINEAR, BOX, HAMMING
except ImportError:
    import ImageFilter, ImageOps, ImageEnhance, __version__, UnidentifiedImageError
    from PIL.Image import BICUBIC, LANCZOS, NEAREST, BILINEAR, BOX, HAMMING
    from PIL import Image
    Image.Resampling = None

但是发现还是对于NoneType进行报错,之前进行了pillow包的更新,不知道是什么原因还是没有找到。再次尝试对于pillow进行更新

出现该报错,完善更新命令,添加--user,更新成功!

pip install --user --upgrade pillow -i https://pypi.tuna.tsinghua.edu.cn/simple

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值