ddddocr
ddddocr copied to clipboard
module 'PIL.Image' has no attribute 'ANTIALIAS'
pillow 高版本没有这个了
我也是这样怎么办
用的哪个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
解决方案:
- 使用低于9.5.0版本的pillow
- 修改源代码,将ddddocr的库文件中所有引用
ANTIALIAS的地方改为新属性LANCZOS - 在你使用ddddocr的程序中,ddddocr引入之前使用这个来让python自动替换属性:
from PIL import Image
if not hasattr(Image, 'ANTIALIAS'):
setattr(Image, 'ANTIALIAS', Image.LANCZOS)