Strange error using ipython -pylab

For some reason, the FIRST time I try to plot something in an ipython
session, I get:

SystemError: ../Objects/moduleobject.c:48: bad argument to internal function

/usr/lib/python2.3/site-packages/matplotlib/pylab.py(774)figtext()

-> ret = gcf().text(*args, **kwargs)

The last entry in the stacktrace is:
/usr/lib/python2.3/site-packages/matplotlib/pylab.py in figtext(*args,
**kwargs) 772 def figtext(*args, **kwargs):
    773
--> 774 ret = gcf().text(*args, **kwargs)
    775 draw_if_interactive()
    776 return ret

After that everything works fine. This error is robust: every first
plot in ipython. Haven't tried command-line yet.

-C

···

--
Charles R. Twardy

Charles R. Twardy wrote:

For some reason, the FIRST time I try to plot something in an ipython
session, I get:

SystemError: ../Objects/moduleobject.c:48: bad argument to internal function

/usr/lib/python2.3/site-packages/matplotlib/pylab.py(774)figtext()

-> ret = gcf().text(*args, **kwargs)

The last entry in the stacktrace is:
/usr/lib/python2.3/site-packages/matplotlib/pylab.py in figtext(*args,
**kwargs) 772 def figtext(*args, **kwargs):
    773
--> 774 ret = gcf().text(*args, **kwargs)
    775 draw_if_interactive()
    776 return ret

After that everything works fine. This error is robust: every first
plot in ipython. Haven't tried command-line yet.

Mmh, this may be the tip of the thread to unravel a long-standing problem which has stumped both John and me several times. I've seen the message

SystemError: ../Objects/moduleobject.c:48: bad argument to internal function

when using the GtkAgg backend, but the funny thing is that the issue wouldn't appear for John even when we were both running _as the same user, on the same box_. The only difference was that I was executing from the console and he was logged in remotely. However, in that case it would always silently segfault, so we never saw the traceback you are seeing, which made the problem very hard to debug without really sinking time into it. But with your behavior, we may get more info.

Some things to try which will help:

1. Version info, for everything (OS, python, ipython, mpl, gcc)

2. In ipython, type 'xmode verbose' before testing, and paste the entire ipython traceback. I don't care if it's big, for this problem anything can help.

3. Backend info. Try cycling through all the backends, and see if the problem appears with all or only with some.

With more details, it may be possible to make some progress on this one...

Cheers,

f

OK, here 'goes. Verbose stacktrace and version info. Haven't tried
other backends, won't tonight.

I. STACKTRACE: 'xmode verbose'

···

-------------------------------------------------------

In [5]:a.plot_status_histograms('Personality')
---------------------------------------------------------------------------
exceptions.SystemError Traceback (most
recent call last)

/home/ctwardy/Projects/SARBayes/Data/Docs/Natsar Report/<console>

/home/ctwardy/Projects/SARBayes/Data/Docs/Natsar Report/sardata.py in
plot_status_histograms(self=<sardata.SarData instance>,
category='Personality')
    788 colors = status_colors,
    789 x_bins = status_order,
--> 790 pies = True)
        global pies = undefined
        global True = undefined
    791
    792 def plot_histograms(self,

/home/ctwardy/Projects/SARBayes/Data/Docs/Natsar Report/sardata.py in
plot_histograms(self=<sardata.SarData instance>, varX='Status',
category='Personality', bigtitle='Status by Personality', colors=['b',
'g', 'r', 'k'], contin=False, grid=False, missing=False, numcols=2,
N_label='N_S', pies=True, x_bins=['Unhurt', 'Injured', 'Fatality', 'No
Trace'], x_label='Status', x_ticks=[0.5, 1.5, 2.5, 3.5],
x_ticklabels=['Unhurt', 'Injured', 'Fatality', 'No Trace'],
y_prop=True)
    902 # Now begin the plotting proper
    903 plotnum = 0
--> 904 figtext(0.5, 0.95, bigtitle, font, fontsize=12)
        global figtext = <function figtext at 0x30806170>
        bigtitle = 'Status by Personality'
        font = {'color': 'k', 'fontweight': 'bold', 'fontname':
'Sans', 'verticalalignment': 'top', 'horizontalalignment': 'center'}
        global fontsize = undefined
    905 for value in values:
    906 plotnum += 1

/usr/lib/python2.3/site-packages/matplotlib/pylab.py in
figtext(*args=(0.5, 0.94999999999999996, 'Status by Personality',
{'color': 'k', 'fontname': 'Sans', 'fontweight': 'bold',
'horizontalalignment': 'center', 'verticalalignment': 'top'}),
**kwargs={'fontsize': 12})
    772 def figtext(*args, **kwargs):
    773
--> 774 ret = gcf().text(*args, **kwargs)
        ret = undefined
        global gcf.text = undefined
        args = (0.5, 0.94999999999999996, 'Status by Personality',
{'color': 'k', 'fontweight': 'bold', 'fontname': 'Sans',
'verticalalignment': 'top', 'horizontalalignment': 'center'})
        kwargs = {'fontsize': 12}
    775 draw_if_interactive()
    776 return ret

SystemError: ../Objects/moduleobject.c:48: bad argument to internal function

/usr/lib/python2.3/site-packages/matplotlib/pylab.py(774)figtext()

-> ret = gcf().text(*args, **kwargs)

II. Versions
----------------------------------

uname -a

Linux amelia 2.6.14-2-powerpc #1 Sat Nov 26 18:12:00 UTC 2005 ppc GNU/Linux

python -V

Python 2.3.5

ipython -V

0.6.15

matplotlib.__version__

'0.85.1.cvs'

gcc --version

gcc (GCC) 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)

On 12/22/05, Fernando Perez <Fernando.Perez@...179...> wrote:

Mmh, this may be the tip of the thread to unravel a long-standing problem
which has stumped both John and me several times. I've seen the message

SystemError: ../Objects/moduleobject.c:48: bad argument to internal function

when using the GtkAgg backend, but the funny thing is that the issue wouldn't
appear for John even when we were both running _as the same user, on the same
box_. The only difference was that I was executing from the console and he
was logged in remotely. However, in that case it would always silently
segfault, so we never saw the traceback you are seeing, which made the problem
very hard to debug without really sinking time into it. But with your
behavior, we may get more info.

Some things to try which will help:

1. Version info, for everything (OS, python, ipython, mpl, gcc)

2. In ipython, type 'xmode verbose' before testing, and paste the entire
ipython traceback. I don't care if it's big, for this problem anything can help.

3. Backend info. Try cycling through all the backends, and see if the problem
appears with all or only with some.

With more details, it may be possible to make some progress on this one...

Cheers,

f

--
Charles R. Twardy

Charles R. Twardy wrote:

OK, here 'goes. Verbose stacktrace and version info. Haven't tried
other backends, won't tonight.

Thanks for the info. Nothing jumps at me, but I was mostly providing you with pointers on what kind of info may help John, who is the one who actually knows that code. I've only bumped into the problem (which he has never found on a machine he works on) and failed to produce any kind of solution. Let's hope some of this flips a switch for him.

Cheers,

f