본문 바로가기

PYTHON/PYTORCH

[파이토치] PILLOW_VERSION 오류 관련

ImportError: cannot import name 'PILLOW_VERSION'

 

이러한 오류를 발견했다면 이것은 pillow 의 버전 문제이다.

 

 

오류 전문

ImportErrorTraceback (most recent call last)
<ipython-input-2-e7ea0c78eaa0> in <module>
      7 import matplotlib.pyplot as plt
      8 from torch.utils.data import Dataset, DataLoader
----> 9 from torchvision import transforms, utils
     10 
     11 # 경고 메시지 무시하기

/usr/local/lib/python3.6/dist-packages/torchvision/__init__.py in <module>
      1 from torchvision import models
----> 2 from torchvision import datasets
      3 from torchvision import ops
      4 from torchvision import transforms
      5 from torchvision import utils

/usr/local/lib/python3.6/dist-packages/torchvision/datasets/__init__.py in <module>
      7 from .svhn import SVHN
      8 from .phototour import PhotoTour
----> 9 from .fakedata import FakeData
     10 from .semeion import SEMEION
     11 from .omniglot import Omniglot

/usr/local/lib/python3.6/dist-packages/torchvision/datasets/fakedata.py in <module>
      1 import torch
      2 from .vision import VisionDataset
----> 3 from .. import transforms
      4 
      5 

/usr/local/lib/python3.6/dist-packages/torchvision/transforms/__init__.py in <module>
----> 1 from .transforms import *

/usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py in <module>
     15 import warnings
     16 
---> 17 from . import functional as F
     18 
     19 if sys.version_info < (3, 3):

/usr/local/lib/python3.6/dist-packages/torchvision/transforms/functional.py in <module>
      3 import sys
      4 import math
----> 5 from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION
      6 try:
      7     import accimage

ImportError: cannot import name 'PILLOW_VERSION'

 

 

현재 내 개발 환경의 pillow 버전은 7.0.0

 

 

 

그래서 개발환경을 다시 정정하였다.

 

torch == 1.2.0

torchvision == 0.4.0

pillow == 6.2.1

 

 

Docker 를 사용할 경우에는 Docker Container를 stop 하고 다시 start 해보시기 바란다. 그냥 했더니 반영 안되고 계속 오류나더라고... 혹은 kernel을 종료하고 다시 할당받아도 될듯 하다.