A fix for pylab and TkAgg plotting in SAGE (Mac OS X)

Lou Pecora pecora at anvil.nrl.navy.mil
Tue Feb 16 15:31:33 EST 2010


A few weeks ago I posted a problem with Mac OS X with matplotlib in the 
SAGE distribution in which attempting to import pylab gave an error 
message which stated that there was an import error and the module 
_tkagg could not be found. The problem appears to be with matplotlib 
(I'm not clear about this).  After much searching and some emailing I 
have found a solution to this problem and it is easy to do.  

Full credit goes to Eric Sonnendrucker who sent it to me.

Here it is:

1) Download the Tcl/Tk sources (go to http://www.tcl.tk/, click on Get 
Tcl/Tk Now, click on Sources Download Page,, download the latest 
version).

2) In the Terminal cd to the unix folder in the tcl folder.  Compile the 
unix version (of Tcl and Tk) as follows 
./configure --enable-framework --disable-xft
make
make install

3) Install SAGE from source.  Download the SAGE source code (go to 
http://www.sagemath.org/, click on Download, click on Download complete 
source code).  In the terminal cd to the SAGE folder and *before* you 
run the sage install you need to set

SAGE_MATPLOTLIB_GUI=True

using export SAGE_MATPLOTLIB_GUI=True with bash. The installer then 
picks it up automatically.

Complete the SAGE installation by typing make and hit return. That's it. 
This will take a while (up to a few hours depending on the computer).

4) You might also need to modify you matplotlibrc by setting 
backend='TkAgg'  after the installation


Test this by doing an import pylab in sage.  You should not get an error.

-- 
-- Lou Pecora



More information about the Python-list mailing list