ImportError:PIL /枕头的库版本不兼容

时间:2019-06-21 13:44:18

标签: python-3.x python-imaging-library imaging

我最近安装了shap,它要求pillow>=4.3.0为:

$ pip3 install shap
Installing collected packages: shap, pillow
Successfully installed pillow-6.0.0 shap-0.29.2

运行使用shap的脚本,我得到了:

Traceback (most recent call last):
  File "Runner.py", line 132, in <module>
    import shap
  File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shap/__init__.py", line 11, in <module>
    from .plots.summary import summary_plot
  File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shap/plots/summary.py", line 15, in <module>
    from . import colors
  File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shap/plots/colors.py", line 7, in <module>
    import skimage.color
  File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/__init__.py", line 135, in <module>
    from .data import data_dir
  File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/data/__init__.py", line 13, in <module>
    from ..io import imread, use_plugin
  File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/io/__init__.py", line 7, in <module>
    from .manage_plugins import *
  File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/io/manage_plugins.py", line 24, in <module>
    from .collection import imread_collection_wrapper
  File "/Users/bravina/Library/Python/3.6/lib/python/site-packages/skimage/io/collection.py", line 10, in <module>
    from PIL import Image
  File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/Image.py", line 93, in <module>
    from . import _imaging as core
ImportError: dlopen(/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so, 2): Library not loaded: @loader_path/.dylibs/libtiff.5.dylib
  Referenced from: /usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so
  Reason: Incompatible library version: _imaging.cpython-36m-darwin.so requires version 10.0.0 or later, but libtiff.5.dylib provides version 8.0.0

如果我直接在python3中尝试也可以做到这一点:

Python 3.6.4 (default, Jan  4 2018, 14:56:03) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/Image.py", line 93, in <module>
    from . import _imaging as core
ImportError: dlopen(/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so, 2): Library not loaded: @loader_path/.dylibs/libtiff.5.dylib
  Referenced from: /usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so
  Reason: Incompatible library version: _imaging.cpython-36m-darwin.so requires version 10.0.0 or later, but libtiff.5.dylib provides version 8.0.0

有关如何解决此问题的任何提示?

1 个答案:

答案 0 :(得分:0)

好吧,this related post中建议的答案都没有对我有用,所以我最终彻底清理并重新安装了python3。从那里,尽可能整洁地在virtualenv中安装必要的软件包似乎可以解决此问题...