0

当我在 python 中运行命令时:

import caffe
img = caffe.io.load_image('bird.jpg')

它引发了一个错误:

ValueError:无法加载“bird.jpg”请参阅以下文档:http ://pillow.readthedocs.org/en/latest/installation.html#external-libraries

我在caffe usersDelbert's Blog找到了一些解决方案,但它们不起作用,我该如何解决?

4

1 回答 1

1

我解决了我的问题,以下是详细信息:

首先,我重新检查此错误信息:

文件“/usr/local/lib/python2.7/dist-packages/scikit_image-0.11.3-py2.7-linux-x86_64.egg/skimage/io/_plugins/pil_plugin.py”,第 52 行,在 imread raise ValueError('Could not load "%s"\n请参阅文档:%s' % (fname, site)) ValueError: Could not load "bird.jpg" 请参阅文档:http ://pillow.readthedocs.org /en/latest/installation.html#external-libraries

这是 imread 的错误我检查了文件pil_plugin.py,我发现它出现了这个错误

im = Image.open(fname)
try:
    # this will raise an IOError if the file is not readable
    im.getdata()[0]
except IOError:
    site = "http://pillow.readthedocs.org/en/latest/installation.html#external-libraries"
    raise ValueError('Could not load "%s"\nPlease see documentation at: %s' % (fname, site))
else:
    return pil_to_ndarray(im, dtype=dtype, img_num=img_num)

所以im.getdata()很可能是错误的,然后我运行它并引发错误:

im.getdata() IOError:读取图像文件时数据流损坏。

然后我按照Matt WD 的解决方案重新安装 jpeg6,删除 Pillow 安装的PIL包,然后通过从http://effbot.org/downloads#pil下载文件重新安装 PIL 。

最后,我链接了libjpeg

ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
sudo ldconfigthe 

错误消失了

于 2016-01-11T09:16:11.170 回答