Python的Tkinter庫的安裝
在FCN代碼中運行infer.py時出現如下錯誤:
File "infer.py", line 4, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "/usr/local/lib/python2.7/dist-packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/usr/local/lib/python2.7/dist-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/usr/local/lib/python2.7/dist-packages/six.py", line 82, in _import_module
__import__(name)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
raise ImportError, str(msg) + ‘, please install the python-tk package‘
ImportError: No module named _tkinter, please install the python-tk package
解決辦法:
Tkinter是Python的GUI widget。一般情況下Linux都沒有自帶,要自己安裝。
1、確定Tkinter沒有安裝:
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 41, in ?
raise ImportError, str(msg) + ‘, please install the python-tk package‘
ImportError: No module named _tkinter, please install the python-tk package
>>>
2、安裝Tkinter:
$sudo apt-get install python-tk
3、安裝成功:
>>> import Tkinter
>>>
Python的Tkinter庫的安裝