Using sage python with GUI

153 views
Skip to first unread message

mankoff

unread,
Dec 14, 2010, 4:13:43 PM12/14/10
to sage-support
Hi Sage Group,

I'm trying to use sage as a means to get a nice python installation,
without actually using sage. I hope this is an OK use of the software.
I imagine I'll transition to using the sage specific tools, but to
start I would like to work with just python.

I have installed sage (4.6) on OS X, and then set PATH, PYTHONPATH,
and DYLD_LIBRARY_PATH to the python distribution in sage. I seems to
work based on the simple test of:

% python
>>> import matplotlib, pylab

neither of which are accessible/usable with the default OS X install.

However, I am now running into a problem when I try to display
graphics with a GUI. If I run this which I think should give me a
simple empty window:

import pylab as P
P.figure()
P.show()

I get this error:

Your currently selected backend, 'agg' does not support show().
Please select a GUI backend in your matplotlibrc file ('/Users/mankoff/
local/sage/local/lib/python2.6/site-packages/matplotlib/mpl-data/
matplotlibrc')
or with matplotlib.use()

I've tried all the options listed in that file (PDF, MacOSX, GTK,
TkAgg, etc.), and also searching online suggested I use code like
this:

import matplotlib as mpl
mpl.use('TkAgg')
import pylab as P
P.figure()
P.show()

But nothing has worked yet. Any advice much appreciated.

Thanks,

-k.

emil

unread,
Dec 15, 2010, 3:49:20 AM12/15/10
to sage-support
have you tried to call

sage -python $*

it should call sages python with the paths set up correctly, so you
can import numpy, etc

Regarding plotting and problems with the backend, I found this link:
http://wiki.sagemath.org/sage_matlab

I don't know if there is a backend included by default, but the link
above should give you an idea how to set one up. I hope this is a
starter ...
emil

mankoff

unread,
Dec 15, 2010, 11:10:07 AM12/15/10
to sage-support
Hi Emil,

Thanks for that link and the sage -python (or -ipython) hint. That is
an easier way to launch python, and yes, I can now have access to all
the python libs that come with sage.

I worked through the steps on the URL you sent but cannot get 'native'
graphics in sage/python. I don't want to recompile matplotlib, sage,
maybe freetype, etc. The whole point of sage (for me) was to not build
these things from the ground up.

I can do without interactive graphics, what I have been looking for
is just a 'native' viewer, where I can plot(x) and see it, rather than
1) plot 2) save to PDF/PNG and 3) use a 3rd party viewer. But for now,
until this part of sage "just works", I think I'll do this 3 step
process.

Thanks,

-k.
Reply all
Reply to author
Forward
0 new messages