Python psd_工具&x27;模块';对象没有属性';profile_frombytes';
运行以下代码:Python psd_工具&x27;模块';对象没有属性';profile_frombytes';,python,macos,python-imaging-library,pillow,Python,Macos,Python Imaging Library,Pillow,运行以下代码: from PIL import * from psd_tools import * psd = PSDImage.load('test.psd') 我收到这个错误: Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> psd = PSDImage.load('test.psd') File "/Library/Python/2.7/site-
from PIL import *
from psd_tools import *
psd = PSDImage.load('test.psd')
我收到这个错误:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
psd = PSDImage.load('test.psd')
File "/Library/Python/2.7/site-packages/psd_tools/user_api/psd_image.py", line 192, in load
return cls.from_stream(fp, encoding)
File "/Library/Python/2.7/site-packages/psd_tools/user_api/psd_image.py", line 200, in from_stream
psd_tools.reader.parse(fp, encoding)
File "/Library/Python/2.7/site-packages/psd_tools/decoder/decoder.py", line 30, in parse
image_resource_blocks = image_resources.decode(reader_parse_result.image_resource_blocks),
File "/Library/Python/2.7/site-packages/psd_tools/decoder/image_resources.py", line 58, in decode
return [parse_image_resource(res) for res in image_resource_blocks]
File "/Library/Python/2.7/site-packages/psd_tools/decoder/image_resources.py", line 68, in parse_image_resource
return resource._replace(data = decoder(resource.data))
File "/Library/Python/2.7/site-packages/psd_tools/decoder/image_resources.py", line 141, in _decode_icc
return ImageCms.ImageCmsProfile(io.BytesIO(data))
File "/Library/Python/2.7/site-packages/PIL/ImageCms.py", line 158, in __init__
self._set(core.profile_frombytes(profile.read()))
AttributeError: 'module' object has no attribute 'profile_frombytes'
枕头版:
2.5.0从卢卡斯·格拉夫那里找到答案。见上面的评论 小CMS需要更新到最新版本
$ brew install little-cms2
$ pip uninstall pillow
$ pip install pillow
您的
PIL
链接的是哪个版本的lcms
?你能把otool-L/Library/Python/2.7/site-packages/PIL/_-imagingcms的输出包括进来吗?那么请在你的问题中加入?另外,你使用的是什么版本的枕头?(import PIL;print PIL.pill\u VERSION
)好的,该枕头版本应具有在\u ImaginageGCMS
上定义的profile\u frombytes
方法(别名为core
)。该方法似乎已经在中引入,这肯定是在2.5.0分支中引入的。因此,我假设问题出在您的lcms
的相当旧的版本上;ImageCms.core.profile_frombytes
适用于我在OS X 10.7.5上使用的lcms-2.2
、PIL-2.5.0
、Python 2.7.1。因此,我建议您尝试升级到lcms2
(之后您需要重建枕头
)。因此,如果您正在使用,请brew安装lcms2
。好的,谢谢--这是为我做的:
$ brew install little-cms2
$ pip uninstall pillow
$ pip install pillow