8

尝试在任何脚本上使用 Pilow 时出现此错误:

  File "/Users/antonio/WWW/myproj/myproj/functions.py", line 12, in <module>
    from PIL import Image, ImageOps
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 53, in <module>
    from PIL import _imaging as core
ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/_imaging.so, 2): Library not loaded: /usr/local/lib/libjpeg.8.dylib
  Referenced from: /usr/local/lib/libtiff.5.dylib
  Reason: Incompatible library version: libtiff.5.dylib requires version 13.0.0 or later, but libjpeg.8.dylib provides version 9.0.0

谁能帮我?

4

5 回答 5

5

我有同样的问题,我不得不重新安装枕头,一切都是依赖关系。我的一些符号链接不好。

首先你必须做:

brew doctor

看看你是否有一些错误。我的是这样的:

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
/usr/local/lib/libjpeg.8.dylib
/usr/local/lib/libpng.3.dylib
/usr/local/lib/libpng12.0.dylib
/usr/local/lib/libpng14.14.dylib

Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .la files:
/usr/local/lib/libjpeg.la
/usr/local/lib/libpng12.la
/usr/local/lib/libpng14.la
/usr/local/lib/libpng15.la

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

 Unexpected .pc files:
/usr/local/lib/pkgconfig/libpng12.pc
/usr/local/lib/pkgconfig/libpng14.pc

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
/usr/local/lib/libjpeg.a
/usr/local/lib/libpng12.a
/usr/local/lib/libpng14.a

所以我决定清除我安装的所有错误和依赖项:

brew uninstall pillow
brew uninstall libpng
brew uninstall libjpeg
brew uninstall webp
brew uninstall libtiff
brew uninstall littlecms

brew prune => to clean symlink

当我的 brew doctor 没有任何错误时,我只是运行brew install pillow并且一切正常。

希望有帮助。

于 2014-03-30T00:26:03.810 回答
3

如果您使用 conda 尝试:

conda install libtiff

或者,如果您不这样做,请尝试:

pip install --upgrade libtiff
于 2016-10-01T02:57:05.580 回答
2

尝试重新安装最新版本的枕头。我使用 anaconda python,并且

conda install -f pillow

为我解决类似的问题。

于 2015-02-12T13:22:45.000 回答
2

我在 OSX 10.10.2 上遇到了非常相似的问题。我还将 anaconda 用于 python,Python 2.7.9 |Anaconda 2.2.0 (x86_64)。Frank 和 user4183543 的答案是值得尝试的好东西,但它们对我不起作用

创建指向已卸载库的软链接对我有用。

我做了:

$ locate libtiff.5.dylib

结果是

/Users/curt/anaconda/lib/libtiff.5.dylib
/Users/curt/anaconda/pkgs/libtiff-4.0.2-1/lib/libtiff.5.dylib

结果libjpeg.8.dylib类似。我通过这些命令为这两者创建了软链接libjpeg.8.dyliblibtiff.5.dylib

$ ln -s /Users/curt/anaconda/lib/libjpeg.8.dylib /usr/local/lib/libjpeg.8.dylib
$ ln -s /Users/curt/anaconda/lib/libtiff.5.dylib /usr/local/lib/libtiff.5.dylib

Pillow / PIL 现在正在为我工​​作,至少目前是这样。

我确信有一个更好的解决方案可以确定核心问题是什么,但我发布这个是为了可能遇到类似问题的 conda 用户。

于 2015-05-19T18:57:01.877 回答
1

我遇到了同样的问题。由于我使用 Anaconda 安装了 Python,“conda install Pillow 在这种情况下确实有效。

于 2015-03-15T19:47:00.423 回答