错误导入python 2.5中的pylab

时间:2014-03-06 16:19:59

标签: python macos matplotlib python-2.5

我试图在python 2.5上运行这个简单的程序并得到以下错误,我不确定发生了什么。

代码:

import pylab
pylab.figure(1) # make figure 1 the current figure
pylab.plot([1,2,3,4], [1,7,3,5]) # draw on figure 1
pylab.show() # show figure on screen

错误:

Traceback (most recent call last):
  File "/Users/sebastiancarrasco/Desktop/Courses/6.00.2x/Week1/plotting-seg1.py", line 3, in <module>
    pylab.figure(1) # make figure 1 the current figure
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/pyplot.py", line 270, in figure
    **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", line 85, in new_figure_manager
    figManager = FigureManagerTkAgg(canvas, num, window)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", line 403, in __init__
    self.toolbar = NavigationToolbar2TkAgg( canvas, self.window )
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", line 670, in __init__
    NavigationToolbar2.__init__(self, canvas)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backend_bases.py", line 2273, in __init__
    self._init_toolbar()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", line 719, in _init_toolbar
    command=self.home)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", line 702, in _Button
    im = Tk.PhotoImage(master=self, file=file)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py", line 3294, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py", line 3250, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
TclError: couldn't open "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/mpl-data/images/home.ppm": permission denied

1 个答案:

答案 0 :(得分:0)

对于遇到此问题并遇到此页面的任何其他人:我最终找到了答案here。长话短说:安装程序的一些问题会影响&#34; images&#34;中所有文件的权限。夹。您所要做的就是更改权限以赋予自己读取权限。