Vision: Pillow 5.1 is broken on OS X

Created on 25 May 2018  路  8Comments  路  Source: pytorch/vision

When installing torch and torchvision in a clean virtualenv with python3.6 and the corresponding pip on OS X

import torchvision

leads to

torch-venv/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so, 2): Symbol not found: _clock_gettime
torch-venv/lib/python3.6/site-packages/PIL/.dylibs/liblzma.5.dylib (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib

This is a known bug see Pillow Issue 3068

As a pytorch user it can be fixed by specifying the Pillow version in your requirements.txt

Pillow!=5.1.0
torch
torchvision

The setup.py should get updated with something like:

install_requires=['Pillow != 5.1.0 ; platform_system = "Darwin"']
bug duplicate transforms

Most helpful comment

@dharmeshkakadia That's a duplicate of https://github.com/pytorch/vision/issues/1712:

We will be releasing a new version of PyTorch and torchvision early next week, so this should be soon fixed.

All 8 comments

@Robin-des-Bois if I understand correctly the problem is with Pillow on OSX, I mean that if you install another version with pip before installing torchvision it should work ?

pip install Pillow!=5.1.0
pip install torchvision

Exactly.

As long as the current version of Pillow is broken, it might make sense to make sure that torchvision's setup.py installs another version (on OS X) so that a potential user does not have to experience a crash when importing torchvision.

I see, maybe if maintainers are OK with what you propose as a change in setup.py and if it is working correctly you could send a PR :

install_requires=['Pillow != 5.1.0 ; platform_system = "Darwin"']

however taking a look at the current setup.py:

'pillow >= 4.1.1',

you would need to adapt the condition with the current state

@Robin-des-Bois I think the issue with MacOSX is also related to the OSX version. I just tested on OSX 10.13.2 the following :

virtualenv --python=python3.6 venv
source venv/bin/activate
(venv) $ python3 --version
> Python 3.6.4
(venv) $ pip3 install torchvision
(venv) $ python3 -c "import torchvision; print(torchvision.__version__)"
> 0.2.1

So, I can not reproduce the issue.

Following the discussion from Pillow, they are almost done with 5.1.1 release

I'm not very sure that we need to change the master now to temporary fix the problem with (let's say old) OSX version and then after their release remove it. What do you think ?

sounds reasonable. especially since the fix as a user is so simple...

I'm not sure there is any action that needs to be taken here from our end.
Closing this, but feel free to comment if you disagree.

@vfdev-5 I can reproduce with the exact same commands you posted. Is there a suggestion on how to fix it? Happy to provide more debugging info if needed as well.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/dharmesh/code/pytorch-CycleGAN-and-pix2pix/venv/lib/python3.6/site-packages/torchvision/__init__.py", line 4, in <module>
    from torchvision import datasets
  File "/Users/dharmesh/code/pytorch-CycleGAN-and-pix2pix/venv/lib/python3.6/site-packages/torchvision/datasets/__init__.py", line 9, in <module>
    from .fakedata import FakeData
  File "/Users/dharmesh/code/pytorch-CycleGAN-and-pix2pix/venv/lib/python3.6/site-packages/torchvision/datasets/fakedata.py", line 3, in <module>
    from .. import transforms
  File "/Users/dharmesh/code/pytorch-CycleGAN-and-pix2pix/venv/lib/python3.6/site-packages/torchvision/transforms/__init__.py", line 1, in <module>
    from .transforms import *
  File "/Users/dharmesh/code/pytorch-CycleGAN-and-pix2pix/venv/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 17, in <module>
    from . import functional as F
  File "/Users/dharmesh/code/pytorch-CycleGAN-and-pix2pix/venv/lib/python3.6/site-packages/torchvision/transforms/functional.py", line 5, in <module>
    from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION
ImportError: cannot import name 'PILLOW_VERSION'

@dharmeshkakadia That's a duplicate of https://github.com/pytorch/vision/issues/1712:

We will be releasing a new version of PyTorch and torchvision early next week, so this should be soon fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ibtingzon picture ibtingzon  路  3Comments

300LiterPropofol picture 300LiterPropofol  路  3Comments

alpha-gradient picture alpha-gradient  路  3Comments

xuanqing94 picture xuanqing94  路  3Comments

Abolfazl-Mehranian picture Abolfazl-Mehranian  路  3Comments