Matplotlib "show()" error Mac OS X Lion

Hi,

I have recently installed Python 32/64bit from Python.org and then I proceeded to install bumpy, scipy, matplotlib and igraph on it. But the Matplotlib does not show the plots even if it opens a Figure window. Here is a summary of what I had done in my installation:

···

-----
I first did a "clean install" by following the instructions at (with an idea to reinstall Matplotlib and see if the rror repeats):
http://matplotlib.sourceforge.net/faq/installing_faq.html#clean-install
-----
So now my python does not have matplotlib:

Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/
Bedarthas-MacBook-Air:Desktop bedartha$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import matplotlib

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib

Bedarthas-MacBook-Air:Desktop bedartha$
-----
Then I downloaded (again) the DMG file at:
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0-py2.7-python.org-macosx10.3.dmg/download
-----
and installed Matplotlib (which seems to go through fine). But after that:

Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/
Bedarthas-MacBook-Air:Desktop bedartha$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import matplotlib as mpl
from pylab import *
plot([1,2,3])

[<matplotlib.lines.Line2D object at 0x2f87fb0>]

show()

Exception in Tkinter callback
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1410, in __call__
    return self.func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 236, in resize
    self.show()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 240, in draw
    tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 19, in blit
    tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
TclError

Bedarthas-MacBook-Air:Desktop bedartha$
-----
Here is the essential info about my machine and my Python and Matplotlib versions:

Bedarthas-MacBook-Air:~ bedartha$ uname -a
Darwin Bedarthas-MacBook-Air.local 11.0.1 Darwin Kernel Version 11.0.1: Wed Jun 29 19:53:22 PDT 2011; root:xnu-1699.23.2~1/RELEASE_X86_64 x86_64
-----
Bedarthas-MacBook-Air:Desktop bedartha$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import matplotlib as mpl
mpl.__version__

'1.1.0'

Bedarthas-MacBook-Air:Desktop bedartha$
-----
I also have the following alias (in ~/.bash_profile) for my Python2.7 (to deal with some issues in igraph):

alias python="arch -i386 python"
-----

Can anyone please help me out?

Best regards,
and apologies for the lengthy post,

Bedartha

As a test, try to set your backend to either ‘cocoaagg’ or ‘macosx’ like so:

import matplotlib as mpl
mpl.use(‘cocoaagg’)

There have been issues with TkAgg on macs. I have personally not had any success with it (even with ActiveState’s Tcl).

Ben Root

···

On Tue, Nov 8, 2011 at 11:15 AM, Bedartha Goswami <goswami@…3385…99…> wrote:

Hi,

I have recently installed Python 32/64bit from Python.org and then I proceeded to install bumpy, scipy, matplotlib and igraph on it. But the Matplotlib does not show the plots even if it opens a Figure window. Here is a summary of what I had done in my installation:


I first did a “clean install” by following the instructions at (with an idea to reinstall Matplotlib and see if the rror repeats):

http://matplotlib.sourceforge.net/faq/installing_faq.html#clean-install


So now my python does not have matplotlib:

Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/

Bedarthas-MacBook-Air:Desktop bedartha$ python

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)

[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

import matplotlib

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named matplotlib

Bedarthas-MacBook-Air:Desktop bedartha$


Then I downloaded (again) the DMG file at:

http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0-py2.7-python.org-macosx10.3.dmg/download


and installed Matplotlib (which seems to go through fine). But after that:

Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/

Bedarthas-MacBook-Air:Desktop bedartha$ python

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)

[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

import matplotlib as mpl

from pylab import *

plot([1,2,3])

[<matplotlib.lines.Line2D object at 0x2f87fb0>]

show()

Exception in Tkinter callback

Traceback (most recent call last):

File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py”, line 1410, in call

return self.func(*args)

File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py”, line 236, in resize

self.show()

File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py”, line 240, in draw

tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)

File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/tkagg.py”, line 19, in blit

tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))

TclError

Bedarthas-MacBook-Air:Desktop bedartha$


Here is the essential info about my machine and my Python and Matplotlib versions:

Bedarthas-MacBook-Air:~ bedartha$ uname -a

Darwin Bedarthas-MacBook-Air.local 11.0.1 Darwin Kernel Version 11.0.1: Wed Jun 29 19:53:22 PDT 2011; root:xnu-1699.23.2~1/RELEASE_X86_64 x86_64


Bedarthas-MacBook-Air:Desktop bedartha$ python

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)

[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

import matplotlib as mpl

mpl.version

‘1.1.0’

Bedarthas-MacBook-Air:Desktop bedartha$


I also have the following alias (in ~/.bash_profile) for my Python2.7 (to deal with some issues in igraph):

alias python=“arch -i386 python”


Can anyone please help me out?

Best regards,

and apologies for the lengthy post,

Bedartha