Qt 없이 Matplotlib만 설치하기
Conda 환경에서 Matplotlib를 설치하면 기본적으로 Qt와 같은 GUI 툴킷이 함께 설치되는 경우가 많습니다. 하지만 GUI 백엔드가 필요 없거나 더 가벼운 환경을 원한다면 matplotlib-base 패키지를 사용하는 것이 좋습니다. 이 패키지는 Qt 등 불필요한 GUI 의존성을 제외한 Matplotlib의 핵심 플로팅 기능만 포함하고 있어, Windows에서도 간편하게 설치할 수 있습니다.
기본 설치 명령어
Conda로 matplotlib-base 패키지를 설치하려면 터미널(Anaconda Prompt)에서 아래 명령어를 실행하십시오.
conda install -c conda-forge matplotlib-base
대부분의 경우 위 명령어 하나면 충분합니다. -c conda-forge 옵션은 Anaconda 기본 채널 대신 커뮤니티가 관리하는 conda-forge 채널에서 패키지를 가져오라는 의미입니다.
대체 채널(라벨) 옵션
특정 버전, 테스트 빌드 또는 과거 호환 빌드가 필요한 경우에는 다음과 같은 라벨 채널을 사용할 수 있습니다.
# 테스트 빌드 conda install -c conda-forge/label/testing matplotlib-base conda install -c conda-forge/label/testing/gcc7 matplotlib-base # 과거 호환 빌드 conda install -c conda-forge/label/cf202003 matplotlib-base conda install -c conda-forge/label/cf201901 matplotlib-base conda install -c conda-forge/label/gcc7 matplotlib-base # 릴리스 후보(RC) conda install -c conda-forge/label/matplotlib_rc matplotlib-base conda install -c conda-forge/label/matplotlib-base_rc matplotlib-base conda install -c conda-forge/label/rc matplotlib-base # 기타 conda install -c conda-forge/label/broken matplotlib-base
주요 옵션 정리
- matplotlib-base: Qt, Tk 같은 GUI 백엔드 없이 핵심 시각화 기능만 제공하는 경량 패키지입니다.
- conda-forge: 다양한 플랫폼과 빌드 변형을 지원하는 신뢰도 높은 커뮤니티 채널입니다.
- 라벨 채널: testing, rc, cf201901 등은 테스트 버전, 릴리스 후보, 구버전 호환 빌드를 제공합니다.
설치 확인
설치가 완료되면 Python 인터프리터에서 아래 코드를 실행해 정상적으로 작동하는지 확인할 수 있습니다.
import matplotlib print(matplotlib.__version__)
버전 정보가 출력되면 Qt 없이 Matplotlib가 성공적으로 설치된 것입니다. 이후 Jupyter Notebook이나 스크립트에서 그래프를 그릴 때는 %matplotlib inline(Jupyter) 또는 Agg 백엔드를 활용하면 GUI 없이도 이미지를 생성할 수 있습니다.