我正在关注this教程的 Matplotlib 。最初我跑了
import numpy as np import matplotlib.pyplot as plt # Compute the x and y coordinates for points on a sine curve x = np.arange(0, 3 * np.pi, 0.1) y = np.sin(x)
当我运行以下
时plt.plot(x, y)
它抛出了以下内容
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/media/abhisek/np/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 3307, in plot
ax = gca()
File "/media/abhisek/np/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 950, in gca
return gcf().gca(**kwargs)
File "/media/abhisek/np/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 586, in gcf
return figure()
File "/media/abhisek/np/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 535, in figure
**kwargs)
File "/media/abhisek/np/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 81, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/media/abhisek/np/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 89, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1818, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable tk.tcl in the following directories:
/usr/share/tcltk/tcl8.6/tk8.6 /usr/share/tcltk/tk8.6 /media/abhisek/np/lib/tk8.6 /usr/local/lib/tcltk/tk8.6 /usr/local/share/tcltk/tk8.6 /usr/lib/tcltk/x86_64-linux-gnu/tk8.6 /usr/lib/tcltk/tk8.6 /usr/lib/tcltk/tcl8.6/tk8.6 /usr/lib/tk8.6 /media/abhisek/lib/tk8.6 /media/abhisek/np/library
This probably means that tk wasn't installed properly.
我正在运行ubuntu 16.04 LTS(64 bit)
并且我没有发现谷歌中发现的任何信息是有用的,或者可能只是我。你能说出如何解决这个问题以及导致这个问题的原因吗?