on
alpine 기반에서 "greenlet" python 패키지 설치시 오류 해결 방법
alpine 기반에서 "greenlet" python 패키지 설치시 오류 해결 방법
문제점 및 증상
alpine 기반으로 python flask 도커 이미지를 생성하던 중에 requirements.txt 파일을 설치하는 과정에서 다음과 같은 오류가 발생하였을 때 해결 방법을 정리합니다.
error: command 'gcc' failed: No such file or directory ---------------------------------------- ERROR: Failed building wheel for greenlet Running setup.py clean for greenlet
또는 다음과 같은 오류가 발생하기도 합니다.
gcc: fatal error: cannot execute 'cc1plus': execvp: No such file or directory compilation terminated. error: command '/usr/bin/gcc' failed with exit code 1 ---------------------------------------- ERROR: Failed building wheel for greenlet Running setup.py clean for greenlet
해결 방안
다음과 같이 파이썬 패키지 설치에 필요한 패키지들을 설치한 후에 "requirements.txt"의 모든 패키지들을 설치하도록 합니다.
RUN apk add --no-cache --virtual .build-deps gcc musl-dev ; \ pip install -r /tmp/requirements.txt ; \ apk del .build-deps gcc musl-dev ; \ rm -f /var/cache/apk/*
위와 같은 RUN 부분을 추가 후, 도커 이미지를 생성하면 alpine linux 패키가 설치된 후, python 필수 패키지들이 정상적으로 설치됩니다.
생성된 도커 이미지를 이용하여 python flask 웹 애플리케이션을 실행해 보았는데, 정상적으로 잘 동작하였습니다.
참고자료
"a gcc problem of pip install in alpine and slim":https://github.com/docker-library/python/issues/318
"Gcc error: gcc: error trying to exec 'cc1': execvp: No such file or directory":https://stackoverflow.com/questions/11912878/
from http://hbesthee.tistory.com/1792 by ccl(A) rewrite - 2021-05-04 20:26:20