ddddocr icon indicating copy to clipboard operation
ddddocr copied to clipboard

module 'PIL.Image' has no attribute 'ANTIALIAS'

Open adgers opened this issue 6 months ago • 3 comments

pillow 高版本没有这个了

adgers avatar Jul 02 '25 07:07 adgers

我也是这样怎么办

paditianxiu avatar Jul 15 '25 12:07 paditianxiu

用的哪个ddddocr的版本以及对应的Python版本是多少? 分享一下我的解决办法

$ python --version
Python 3.13.7
$ pip show ddddocr
Name: ddddocr
Version: 1.0.6
...

在ddddocr的目录中,找到__init__.py文件,在DdddOcr这个类的classification方法中,把Image.ANTIALIAS改成Image.LANCZOS

yuryqwer avatar Sep 24 '25 07:09 yuryqwer

解决方案:

  • 使用低于9.5.0版本的pillow
  • 修改源代码,将ddddocr的库文件中所有引用 ANTIALIAS 的地方改为新属性 LANCZOS
  • 在你使用ddddocr的程序中,ddddocr引入之前使用这个来让python自动替换属性:
from PIL import Image
if not hasattr(Image, 'ANTIALIAS'):
    setattr(Image, 'ANTIALIAS', Image.LANCZOS)

NanCunChild avatar Oct 04 '25 08:10 NanCunChild