在python 2.5中导入pylab时出错

在python 2.5中导入pylab时出错,python,macos,matplotlib,python-2.5,Python,Macos,Matplotlib,Python 2.5,我试图在Python2.5上运行这个简单的程序,但得到了以下错误,我不确定发生了什么 代码: 错误: 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

我试图在Python2.5上运行这个简单的程序,但得到了以下错误,我不确定发生了什么

代码:

错误:

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
回溯(最近一次呼叫最后一次):
文件“/Users/sebastiancarrasco/Desktop/Courses/6.00.2x/Week1/plotting-seg1.py”,第3行,在
pylab.图(1)#使图1成为当前图
文件“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site packages/matplotlib/pyplot.py”,图中第270行
**kwargs)
文件“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site packages/matplotlib/backends/backend\u tkagg.py”,第85行,在new\u figure\u manager中
figManager=FigureManagerTkAgg(画布、数字、窗口)
文件“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site packages/matplotlib/backends/backend_-tkagg.py”,第403行,在__
self.toolbar=NavigationToolbar2TkAgg(画布,self.window)
文件“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site packages/matplotlib/backends/backend_-tkagg.py”,第670行,在_-init中__
导航工具栏2.\uuuu初始化\uuuuuuu(自我,画布)
文件“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site packages/matplotlib/backend_base.py”,第2273行,在__
self.\u init\u工具栏()
文件“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site packages/matplotlib/backends/backend\u tkagg.py”,第719行,在_init\u工具栏中
command=self.home)
文件“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site packages/matplotlib/backends/backend_-tkagg.py”,第702行,在_按钮中
im=Tk.PhotoImage(master=self,file=file)
文件“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py”,第3294行,在__
图像。_u初始(自我,“照片”,名称,cnf,主机,**千瓦)
文件“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py”,第3250行,在__
self.tk.call(('image','create',imgtype,name,)+选项)
Tcl错误:无法打开“/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site packages/matplotlib/mpl data/images/home.ppm”:权限被拒绝

对于遇到此问题并看到此页面的其他人:我最终找到了答案。长话短说:安装程序的一些问题将“images”文件夹中所有文件的权限搞乱了。您所要做的就是更改权限以授予自己阅读权限。

您的用户似乎没有权限打开
home.ppm
文件。您可能需要单独为用户安装matplotlib模块,或者将其安装在python虚拟环境中。您还使用的mac电脑在安装科学python堆栈方面是出了名的不友好。
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