IPython 에서 matplotlib import 시 cannot import name 'QtCore' 오류 발생 처리
Think Stats 2 PDF 를 보다가 첫 SOURCE 코드를 테스트 시 오류가 발생하였다.
확인해 보니 IPython에서 matplotlib 를 import 시 cannot import name 'QtCore' 오류 발생 처리
내 PC의 Python 버전은 3.4이다. , matplotlib 를 import 시 QtCore 5와 QtCore 4 간에 불일치로 문제가 발생되는 것 같다.
아래와 같이 matplotlib.use("Qt5Agg") 를 IPython에서 수행하여 해결하였다. 이 때 주의할 사항이 있는데 오류가 난 Ipython 콘솔에서 해당 설정을 수행하면 Warning 메시지가 나오면서 이미 Backend가 설정되어 해당 설정은 적용되지 않는다는 것이다. 반드시 새로운 콘솔창을 열고 해당 명령어를 입력하자.
import matplotlib
matplotlib.use("Qt5Agg")
C:\Anaconda3\lib\site-packages\matplotlib\__init__.py:1350: UserWarning: This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
반드시 새로운 콘솔창을 열고 해당 메시지를 입력하자.
'개발 > Python' 카테고리의 다른 글
Numpy 와 Pandas에서 불리언 색인(Boolean Index) 의 활용 (0) | 2016.09.25 |
---|---|
with.. as 절의 사용법 (0) | 2016.09.21 |
Python mmap(Memory Mapped File) 함수 (0) | 2016.09.20 |
Numpy array 를 shape로 차원확인 하기 (0) | 2016.09.19 |
Python에서는 증감연산자 ++,-- 가 없다 (0) | 2016.09.19 |