Python psd_tools:‘module’对象没有属性‘profile_frombytes’

1 投票
1 回答
1036 浏览
提问于 2025-04-18 12:01

运行以下代码:

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'

我已经重新安装了PIL、Pillow、psd-tools和相关的依赖项。

我现在不知道该怎么解决这个问题。

我在Mac OSX 10.7.5上运行Python 2.7

编辑:这是你们要求的输出--

/Library/Python/2.7/site-packages/PIL/_imagingcms.so:
    /usr/local/lib/liblcms.1.0.19.dylib (compatibility version 2.0.0, current version 2.19.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

Pillow版本:

2.5.0

1 个回答

1

这个答案是Lukas Graf提供的。可以查看上面的评论。

需要把Little CMS更新到最新版本。

$ brew install little-cms2
$ pip uninstall pillow
$ pip install pillow

撰写回答