How can Pillow and MATLAB Runtime be use

In order to use the MATLAB runtime on macOS, the DYLD_LIBRARY_PATH must be updated to point to the MATLAB Runtime.
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/MATLAB_R2017b.app/runtime/maci64:/Applications/MATLAB_R2017b.app/sys/os/maci64:/Applications/MATLAB_R2017b.app/bin/maci64
Then, to use Pillow, it must be installed:
$ pip3 install Pillow
When running the following code:
from PIL import Image, ImageTk
print('Hello World')
The following error is shown:
Traceback (most recent call last):
File "main.py", line 1, in <module>
from PIL import Image, ImageTk
File "/Users/user/venv/py-test/lib/python3.6/site-packages/PIL/Image.py", line 58, in <module>
from . import _imaging as core
ImportError: dlopen(/Users/user/venv/py-test/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so, 2): Library not loaded: @loader_path/.dylibs/libtiff.5.dylib
Referenced from: /Users/user/venv/py-test/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so
Reason: Incompatible library version: _imaging.cpython-36m-darwin.so requires version 9.0.0 or later, but libtiff.5.dylib provides version 6.0.0
If run without the first export command, Pillow works fine, but I can't find out a way to get both to work at once. The MATLAB Runtime is exporting an older version of libtiff that Pillow (even though it's install via a binary wheel) is loading:
/Applications/MATLAB_R2017b.app/bin/maci64/libtiff.5.dylib
System configuration
  • macOS 10.11.6
  • Python 3.6.4 installed via Homebrew
  • Pillow 5.0.0
  • MATLAB Runtime 2017b

Answers (0)

Categories

Products

Asked:

on 21 Mar 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!