본문 바로가기

웹 개발/Django

[Django] Windows 개발환경에서 Pillow 설치 오류 해결

본인이 사용하는 개발환경은 다음과 같다.

====================================

Windows 10 Home 64비트 운영 체제

Pycharm Professional 2019.2.4 (build 192.7142.42)

Python 3.8

Django 3.0.1

pip 19.0.1

====================================

 

Django를 이용해 인스타그램 클론코딩 연습을 하던 중 이미지 업로드를 위해 Pillow 라는 패키지를 설치하려고 했다.

하지만 다음과 같은 오류가 발생했다.

전체 오류 메세지는 https://github.com/python-pillow/Pillow/issues/4242

 

The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source. · Issue #4242

I have trouble installing Pillow in my virtual environment on windows. I an using: windows 19 64-bit Python 3.8 64-bit pip Version 19.03 setuptools 40.8.0 When ever i try to use pip/pip3 install pi...

github.com

이곳에 올라온 오류 내용과 완전히 같은 내용이고 핵심은 위의 캡쳐 부분이다.

 

위 링크의 글을 읽기 전에 구글링 해보며 얻어낸 정보가 있었다.

반응형

1. 파이썬 버전과 Pillow 버전이 맞지 않다. 

    => 오류 메세지에서 읽기를 권장한 https://pillow.readthedocs.io/en/latest/installation.html 에 가서 살펴보니

         본인이 설치하려한 버전(6.2.1)과 파이썬 버전(3.8)의 호환 문제는 아니었다.

 

그 외의 정보들은 Windows 에서 불가능하거나 다른 내용이었다.

 

본인은 저 오류메세지를 읽고 zlib이라는 파이썬 표준 라이브러리를 처음 알게 되었다. 

zlib이라는 프로그램을 설치해야하는 줄 알고 헤매다 다른 방법을 찾게 되었다.

위의 링크 https://github.com/python-pillow/Pillow/issues/4242 

 

The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source. · Issue #4242

I have trouble installing Pillow in my virtual environment on windows. I an using: windows 19 64-bit Python 3.8 64-bit pip Version 19.03 setuptools 40.8.0 When ever i try to use pip/pip3 install pi...

github.com

이곳에서 글을 계속 읽다보니 pip를 최신버전으로 재설치 했더니 해결되었다고 한다. 

그래서 글에 나온대로 python -m pip install -U --force-reinstall pip 해보았다.

 

하지만 재설치 중 다음과 같은 오류가 또 발생하였다.

이 문제는 다행이도 금방 해결 방법을 찾을 수 있었다.

https://hg4535.tistory.com/entry/pip-%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8-%EC%97%90%EB%9F%AC-%EC%9E%AC%EC%84%A4%EC%B9%98-NoneType-object-has-no-attribute-bytes

 

pip 업데이트 에러 ( 재설치) 'NoneType' object has no attribute 'bytes'

(venv) D:\study\deeplearning\untitled>pip3 install --upgrade pip ERROR: To modify pip, please run the following command: D:\study\deeplearning\untitled\venv\Scripts\python.exe -m pip install --upg..

hg4535.tistory.com

출처: https://hg4535.tistory.com/entry/pip-업데이트-에러-재설치-NoneType-object-has-no-attribute-bytes [일상(日常)]

 

위 블로그에서 제안한 방법으로

pip install -U --force-reinstall pip는 아까 시도했으나 실패해서

easy_install -U pip를 사용하여 해결했다.

 

pip를 성공적으로 재설치 한 후

다시 터미널에 pip install Pillow 를 실행시켜

다음과 같이 설치에 성공했다.

 

요약 ==========================================

1. pip가 구버전이다. 최신버전으로 업데이트 해야한다.

2. pip install -U --force-reinstall pip 를 하거나 easy_install -U pip 를 하면 된다.