linux mint 13开始就发现这个问题了,一直不知道怎么解决,今天突然发现了解决方案,来分享给大家
下面是修改对比,自己根据修改,这个是系统文件,需要root权限,路径/usr/lib/python2.7/dist-packages/PIL/ImageDraw.py
+import numbers
+
from PIL import Image, ImageColor try:
@@ -98,7 +100,7 @@ def setink(self, ink):
)
if Image.isStringType(ink):
ink = ImageColor.getcolor(ink, self.mode)
- if self.palette and not Image.isNumberType(ink):
+ if self.palette and not isinstance(ink, numbers.Number):
ink = self.palette.getcolor(ink)
self.ink = self.draw.draw_ink(ink, self.mode) @@ -141,13 +143,13 @@ def _getink(self, ink, fill=None):
if ink is not None:
if Image.isStringType(ink):
ink = ImageColor.getcolor(ink, self.mode)
- if self.palette and not Image.isNumberType(ink):
+ if self.palette and not isinstance(ink, numbers.Number):
ink = self.palette.getcolor(ink)
ink = self.draw.draw_ink(ink, self.mode)
if fill is not None:
if Image.isStringType(fill):
fill = ImageColor.getcolor(fill, self.mode)
- if self.palette and not Image.isNumberType(fill):
+ if self.palette and not isinstance(fill, numbers.Number):
fill = self.palette.getcolor(fill)
fill = self.draw.draw_ink(fill, self.mode)
return ink, fill
修改完之后就不会报错了
File "/usr/lib/python2.7/dist-packages/PIL/ImageDraw.py", line 256, in text
ink, fill = self._getink(fill)
File "/usr/lib/python2.7/dist-packages/PIL/ImageDraw.py", line 144, in _getink
if self.palette and not Image.isNumberType(ink):
AttributeError: 'module' object has no attribute 'isNumberType'