728x90
우분투 환경의 파이썬 3.6 버전의 경우 PIL 패키지 설치시 아래와 같이 UnsatisfiableError 를 반환한다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ModuleNotFoundError Traceback (most recent call last) <ipython-input-10-febbdbbc8b02> in <module> 1 from IPython.display import display ----> 2 from PIL import image 3 4 classifier.fit_generator( 5 training_set, ModuleNotFoundError: No module named 'PIL' (tfKeras) founder@hilbert:~$ conda install -c anaconda pil Solving environment: failed UnsatisfiableError: The following specifications were found to be in conflict: - matplotlib-base -> freetype[version='>=2.9.1,<3.0a0'] - pil -> freetype=2.4 Use "conda info <package>" to see the dependencies for each package. | cs |
PIL 홈페이지(http://www.pythonware.com/products/pil/)를 보면, 파이썬 3.x 를 지원하지 않음을 알 수 있다. 이 경우 pillow 를 사용하면 된다. 다음과 같이 설치한다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | (tfKeras) founder@hilbert:~$ conda install pillow Solving environment: done ## Package Plan ## environment location: /home/founder/anaconda3/envs/tfKeras added / updated specs: - pillow The following packages will be downloaded: package | build ---------------------------|----------------- olefile-0.46 | py36_0 48 KB python-3.6.7 | h0371630_0 34.3 MB ca-certificates-2018.03.07 | 0 124 KB pillow-5.3.0 | py36h34e0f95_0 599 KB ------------------------------------------------------------ Total: 35.0 MB The following NEW packages will be INSTALLED: libtiff: 4.0.9-he85c1e1_2 olefile: 0.46-py36_0 pillow: 5.3.0-py36h34e0f95_0 The following packages will be UPDATED: ca-certificates: 2018.03.07-0 anaconda --> 2018.03.07-0 certifi: 2018.10.15-py36_0 anaconda --> 2018.11.29-py36_0 python: 3.6.7-h0371630_0 anaconda --> 3.6.7-h0371630_0 The following packages will be DOWNGRADED: openssl: 1.1.1-h7b6447c_0 anaconda --> 1.1.1a-h7b6447c_0 Proceed ([y]/n)? y Downloading and Extracting Packages olefile-0.46 | 48 KB | ###################################################################################### | 100% python-3.6.7 | 34.3 MB | ###################################################################################### | 100% ca-certificates-2018 | 124 KB | ###################################################################################### | 100% pillow-5.3.0 | 599 KB | ###################################################################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done | cs |
정상적으로 설치를 했음에도 여전히 다음과 같은 오류가 나타난다.
1 2 | ImportError: Could not import PIL.Image. The use of `array_to_img` requires PIL. | cs |
이와 관련하여 스택오버플로우를 찾아보면, pip 설치 후 아나콘다 등의 가상환경을 재시작하지 않은 경우 이럴 수 있다고 나와있다.
https://stackoverflow.com/questions/41124353/importerror-could-not-import-the-python-imaging-library-pil-required-to-load
아나콘다 환경을 비활성화시킨 후 다시 활성화시키면 정상적으로 작동함을 알 수 있다.
728x90