matplotlib.use() error

Updating matplotlib with a new SVN build a couple days ago induced
the following error:

RuntimeError: matplotlib.use() must be called *before* pylab
or matplotlib.backends is imported for the first time.

This has not occurred before. Am I to understand that once pylab
is imported, you cannot change backends? That seems strange. Is
there a way of side-stepping this?

Chris wrote:

Updating matplotlib with a new SVN build a couple days ago induced
the following error:

RuntimeError: matplotlib.use() must be called *before* pylab
or matplotlib.backends is imported for the first time.

This has not occurred before. Am I to understand that once pylab
is imported, you cannot change backends? That seems strange. Is there a way of side-stepping this?

This has long been the case, but only recently was an error added. (It was confusing to many who *thought* they were changing the backend, when in fact they weren't.)

I don't know of any way to side step this -- for various reasons, the backend must be known during pylab initialization. It might be possible with fairly significant refactoring... maybe someone has looked deeper into this than I have.

Cheers,
Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

There is a "switch_backends" function in pylab that attempts to do a
post import switching. It works reasonably well, but is not
recommended for switching across threaded GUI backends (eg in
ipython), which is why it has mostly remained an experimental feature.

JDH

···

On 10/9/07, Michael Droettboom <mdroe@...86...> wrote:

I don't know of any way to side step this -- for various reasons, the
backend must be known during pylab initialization. It might be possible
with fairly significant refactoring... maybe someone has looked deeper
into this than I have.