module '_tkinter' has no attribute '__file__'

1926 ワード

構成リスト:
python3.5
matplotlib1.5.3
...関連構成
試験手順:
import matplotlib
matplotlib.use('tkagg')

import matplotlib.pyplot as plt
plt.plot([1,2,3,4,5],[4,3,5,6,3])
plt.show()

質問:
ipythonインタフェースに入り、matplotlibを使用すると、
import matplotlib.pyplot as plt
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
 in ()
----> 1 import matplotlib.pyplot as plt

/usr/local/python-3.5/lib/python3.5/site-packages/matplotlib/pyplot.py in ()
    112 
##############################################  ##########################################################################
/usr/local/python-3.5/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py in ()
     11 
     12 # Paint image to Tk photo blitter extension
---> 13 import matplotlib.backends.tkagg as tkagg
     14 
     15 from matplotlib.backends.backend_agg import FigureCanvasAgg


/usr/local/python-3.5/lib/python3.5/site-packages/matplotlib/backends/tkagg.py in ()
      7 import numpy as np
      8 
----> 9 from matplotlib.backends import _tkagg
     10 
     11 def blit(photoimage, aggimage, bbox=None, colormode=1):


AttributeError: module '_tkinter' has no attribute '__file__'

考え方:
これはmatplotlib 1と初歩的に考えられる.5.3のバグ
解決手順:
(1)pip list現在のmatplotlibのバージョンを表示します.matplotlib 1.5.3です.(pip install matplotlibインストール時のデフォルトインストール1.5.3)
(2)通過https://pypi.python.org/pypiああ、最新版のmatplotlibをクエリーします.今は2.0です.0rc2  
(3)現在のmatplotlib,pip uninstall matplotlibをアンインストールする
(4)指定バージョンのmatplotlib,pip install matplotlib=2.0.0 rc 2をインストールする
(5)matplotlibを再度使用し、問題は解決した