Bug: mad interference between matplotlib and openbabel

Thanks for your fast replies! As suggested I removed all "from import*"
statements. I used "import pylab" and "import pylab as p" statements but
it do s not work either. :-@

Could you recommend other "easy to handle " python plotting libs?

Thanx!

Darren Dale wrote:

···

On Thu, Jun 26, 2008 at 5:51 AM, Florian Koelling > <florian.koelling@...2064... <mailto:florian.koelling@…2064…>> wrote:

    Hi folks!

    I' m working on a code to identify ligand's information from pdb
    crystal
    structures. For this purpose I use the openbabel package. I' m
    encoding
    the ligand's information in smarts.
    For checking if the smarts are assigned correctly I 'm writing a sdf
    file (to control whether the features are placed correctly).

    This part works fine - but I get into deep trouble when I try to plot
    simple count statistics of my smarts, when I use the "from pylab
    import*" , or "from pylab import matplotlib" statements (trouble
    appears
    just after IMPORTING - I do not use a pylab function in this state of
    the program yet):

Avoid all use of "from package import *". When you import *, strange
things can happen, since one import can overwrite things from a
previous import. Try "import pylab" or "import pylab as plt", that way
all the pylab functionality remains in its own namespace and cant be
overwritten, and can't overwrite anything else. Finally, "from pylab
import matplotlib" won't work, matplotlib is a top-level package.

Thanks for your fast replies! As suggested I removed all "from import*"
statements. I used "import pylab" and "import pylab as p" statements but
it do s not work either. :-@

It was a good guess. You have a software version conflict apparently,
and yet you haven't provided us any version numbers of the packages
you are using -- that makes it pretty hard to progress. One thing I
notice is that you import Numeric, which is the predecessor to numpy.
All recent versions of matplotlib/pylab import numpy by default,
though some older versions can be configured to use Numeric, numarray
or numpy using a numerix setting. It is possible that you are seeing
a Numeric/numpy conflict somewhere. I am not sure what openbabel and
pybel are doing internally vis-a-vis numpy/numeric, though I do see
that there are some problems passing numpy scalars to openbabel at
http://openbabel.org/wiki/Python.

Could you recommend other "easy to handle " python plotting libs?

chaco is quite nice - http://code.enthought.com/chaco.

But we would like to sort out this problem for future reference, so if
you'd be willing to stick with it and help us figure out where the
conflict is coming from, it will help the future users. My first
suggestion is to see if you need Numeric, or if numpy will suffice,
and make sure you are using it consistently throughout. My second
suggestion is to figure out of there are any gui toolkits in the
openbabel chain, and if so make sure your backend setting in
matplotlib is consistent with them (though the gui mainloop will not
be triggered by simply importing pylab, you must also call pylab.show,
so I don't know why that would cause a problem per se).

In any follow-up emails, please post the versions of all software you
are importing. One could way to get the matplotlib version info is to
create a simple script::

  import pylab
  pylab.plot([1,2,3])
  pylab.show()

and run it with::

  > python myscript.py --verbose-helpful

and post the output here.

JDH

···

On Thu, Jun 26, 2008 at 7:04 AM, Florian Koelling <florian.koelling@...2064...> wrote: