码迷,mamicode.com
首页 > 编程语言 > 详细

Python的Tkinter库的安装

时间:2017-09-27 13:12:16      阅读:754      评论:0      收藏:0      [点我收藏+]

标签:oba   named   last   import   res   glob   get   self   agg   

 

在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库的安装

标签:oba   named   last   import   res   glob   get   self   agg   

原文地址:http://www.cnblogs.com/xiaoxiao9292/p/7600669.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!