Croizat on Mac OS X

Hi Mauro & Lionel,

I tried changing the backend to WX (and WxAgg) via the matplotlibrc file, but got the same result. Other suggestions welcome!

Nick

WX:

···

==================
mws2:/bioinformatics/croizat/Croizat nick$ py Croizat.py

matplotlib data path /Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/matplotlib-0.98.3.0001-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data
loaded rc file /Users/nick/.matplotlib/matplotlibrc
matplotlib version 0.98.3
verbose.level helpful
interactive is True
units is False
platform is darwin
numerix numpy 1.1.1
$HOME=/Users/nick
CONFIGDIR=/Users/nick/.matplotlib
Using fontManager instance from /Users/nick/.matplotlib/fontManager.cache
backend WX version 2.8.7.1
Traceback (most recent call last):
   File "Croizat.py", line 71, in <module>
     Croizat = Application(0)
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/wxPython-2.8.7.1.0003_s-py2.5-macosx-10.3-fat.egg/wx/_core.py", line 7836, in __init__
     self._BootstrapApp()
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/wxPython-2.8.7.1.0003_s-py2.5-macosx-10.3-fat.egg/wx/_core.py", line 7433, in _BootstrapApp
     return _core_.PyApp__BootstrapApp(*args, **kwargs)
   File "Croizat.py", line 62, in OnInit
     MainWindow = MainForm(None, -1, "")
   File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 201, in __init__
   File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 320, in __do_layout
   File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 1187, in DrawMap
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py", line 1361, in drawcoastlines
     self.set_axes_limits(ax=ax)
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py", line 2501, in set_axes_limits
     figManager.canvas.draw()
AttributeError: 'NoneType' object has no attribute 'canvas'

WxAgg:

mws2:/bioinformatics/croizat/Croizat nick$ py Croizat.py

matplotlib data path /Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/matplotlib-0.98.3.0001-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data
loaded rc file /Users/nick/.matplotlib/matplotlibrc
matplotlib version 0.98.3
verbose.level helpful
interactive is True
units is False
platform is darwin
numerix numpy 1.1.1
$HOME=/Users/nick
CONFIGDIR=/Users/nick/.matplotlib
Using fontManager instance from /Users/nick/.matplotlib/fontManager.cache
backend WXAgg version 2.8.7.1
Traceback (most recent call last):
   File "Croizat.py", line 71, in <module>
     Croizat = Application(0)
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/wxPython-2.8.7.1.0003_s-py2.5-macosx-10.3-fat.egg/wx/_core.py", line 7836, in __init__
     self._BootstrapApp()
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/wxPython-2.8.7.1.0003_s-py2.5-macosx-10.3-fat.egg/wx/_core.py", line 7433, in _BootstrapApp
     return _core_.PyApp__BootstrapApp(*args, **kwargs)
   File "Croizat.py", line 62, in OnInit
     MainWindow = MainForm(None, -1, "")
   File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 201, in __init__
   File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 320, in __do_layout
   File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 1187, in DrawMap
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py", line 1361, in drawcoastlines
     self.set_axes_limits(ax=ax)
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py", line 2501, in set_axes_limits
     figManager.canvas.draw()
AttributeError: 'NoneType' object has no attribute 'canvas'

mws2:/bioinformatics/croizat/Croizat nick$

Mauro Cavalcanti wrote:

Dear Nick,

I got this reply from one of the members of the Matplotlib-users
discussion list. I don't know if it will help, but maybe a start.

Another suggestion I may give you just occurred me yesterday: try
deleting all the .pyc files included in the "Croizat" distribution
archive, then go to the /source sub-folder of the installation folder
and run the Croizat.py file from there. The Python interpreter will
recompile the code and rebuild the .pyc files in the source folder.
Maybe this will help. Anyway, let me know the results.

With warmest regards,

---------- Forwarded message ----------
From: Lionel Roubeyrie <lroubeyrie@...1068...>
Date: 2009/1/22
Subject: Re: [Matplotlib-users] Fwd: Croizat on Mac OS X
To: Matplotlib Users <matplotlib-users@lists.sourceforge.net>

Maybe a backend problem, since your soft is based on wx and the user
uses Tk :
...

Using fontManager instance from /Users/nick/.matplotlib/fontManager.cache
backend TkAgg version 8.4
Traceback (most recent call last):
File "Croizat.py", line 71, in <module>
   Croizat = Application(0)

...
--
Lionel Roubeyrie
charg� d'�tudes
LIMAIR - La Surveillance de l'Air en Limousin
http://www.limair.asso.fr

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--

Nicholas J. Matzke
Ph.D. student, Graduate Student Researcher
Huelsenbeck Lab
Center for Theoretical Evolutionary Genomics
4151 VLSB (Valley Life Sciences Building)
Department of Integrative Biology
University of California, Berkeley

Lab websites:
http://ib.berkeley.edu/people/lab_detail.php?lab=54
http://fisher.berkeley.edu/cteg/hlab.html
Dept. personal page:
http://ib.berkeley.edu/people/students/person_detail.php?person=370
Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
Lab phone: 510-643-6299
Dept. fax: 510-643-6264
Cell phone: 510-301-0179
Email: matzke@...1016...

Mailing address:
Department of Integrative Biology
3060 VLSB #3140
Berkeley, CA 94720-3140

-----------------------------------------------------
"[W]hen people thought the earth was flat, they were wrong. When people
thought the earth was spherical, they were wrong. But if you think that
thinking the earth is spherical is just as wrong as thinking the earth
is flat, then your view is wronger than both of them put together."

Isaac Asimov (1989). "The Relativity of Wrong." The Skeptical Inquirer,
14(1), 35-44. Fall 1989.
http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm

Hi Mauro,

Update:

1. I went to the place that threw an error in the basemap code:

>> "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py",

>> line 2501, in set_axes_limits
>> figManager.canvas.draw()
>> AttributeError: 'NoneType' object has no attribute 'canvas'
>>

The code is:

···

============
         # force draw if in interactive mode.
         if is_interactive():
             figManager = _pylab_helpers.Gcf.get_active()
             figManager.canvas.draw()

So, I changed "interactive = true" to "interactive = false" in my matplotlibrc file.

Now when I run "python Croizat.py", I get no error messages, and the graphic of a world map comes up.

I can get rivers etc. to display correctly.

2. However, I tried opening the America.prj project file, and the various *.csv files in the /samples directory, and couldn't get anything to display (perhaps because interactive mode is off?).

When I clicked on the the various analysis options (e.g. track analysis), I get "Number of data files must be >= 1". This probably means the files aren't actually loading...

2a. Workaround: When I copied the *.prj file and the *.csv files from Croizat/sample to the main Croizat directory, then I was able to open things fine, and run the analyses.

So basically it looks like it works now. Recommend you post this where appropriate for other users.

Cheers!
Nick

Nick Matzke wrote:

Hi Mauro & Lionel,

I tried changing the backend to WX (and WxAgg) via the matplotlibrc file, but got the same result. Other suggestions welcome!

Nick

WX:

mws2:/bioinformatics/croizat/Croizat nick$ py Croizat.py

matplotlib data path /Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/matplotlib-0.98.3.0001-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data

loaded rc file /Users/nick/.matplotlib/matplotlibrc
matplotlib version 0.98.3
verbose.level helpful
interactive is True
units is False
platform is darwin
numerix numpy 1.1.1
$HOME=/Users/nick
CONFIGDIR=/Users/nick/.matplotlib
Using fontManager instance from /Users/nick/.matplotlib/fontManager.cache
backend WX version 2.8.7.1
Traceback (most recent call last):
  File "Croizat.py", line 71, in <module>
    Croizat = Application(0)
  File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/wxPython-2.8.7.1.0003_s-py2.5-macosx-10.3-fat.egg/wx/_core.py", line 7836, in __init__
    self._BootstrapApp()
  File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/wxPython-2.8.7.1.0003_s-py2.5-macosx-10.3-fat.egg/wx/_core.py", line 7433, in _BootstrapApp
    return _core_.PyApp__BootstrapApp(*args, **kwargs)
  File "Croizat.py", line 62, in OnInit
    MainWindow = MainForm(None, -1, "")
  File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 201, in __init__
  File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 320, in __do_layout
  File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 1187, in DrawMap
  File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py", line 1361, in drawcoastlines
    self.set_axes_limits(ax=ax)
  File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py", line 2501, in set_axes_limits
    figManager.canvas.draw()
AttributeError: 'NoneType' object has no attribute 'canvas'

WxAgg:

mws2:/bioinformatics/croizat/Croizat nick$ py Croizat.py

matplotlib data path /Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/matplotlib-0.98.3.0001-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data

loaded rc file /Users/nick/.matplotlib/matplotlibrc
matplotlib version 0.98.3
verbose.level helpful
interactive is True
units is False
platform is darwin
numerix numpy 1.1.1
$HOME=/Users/nick
CONFIGDIR=/Users/nick/.matplotlib
Using fontManager instance from /Users/nick/.matplotlib/fontManager.cache
backend WXAgg version 2.8.7.1
Traceback (most recent call last):
  File "Croizat.py", line 71, in <module>
    Croizat = Application(0)
  File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/wxPython-2.8.7.1.0003_s-py2.5-macosx-10.3-fat.egg/wx/_core.py", line 7836, in __init__
    self._BootstrapApp()
  File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/wxPython-2.8.7.1.0003_s-py2.5-macosx-10.3-fat.egg/wx/_core.py", line 7433, in _BootstrapApp
    return _core_.PyApp__BootstrapApp(*args, **kwargs)
  File "Croizat.py", line 62, in OnInit
    MainWindow = MainForm(None, -1, "")
  File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 201, in __init__
  File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 320, in __do_layout
  File "/home/maurobio/Projetos/Croizat/source/MainForm.py", line 1187, in DrawMap
  File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py", line 1361, in drawcoastlines
    self.set_axes_limits(ax=ax)
  File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py", line 2501, in set_axes_limits
    figManager.canvas.draw()
AttributeError: 'NoneType' object has no attribute 'canvas'

mws2:/bioinformatics/croizat/Croizat nick$

Mauro Cavalcanti wrote:

Dear Nick,

I got this reply from one of the members of the Matplotlib-users
discussion list. I don't know if it will help, but maybe a start.

Another suggestion I may give you just occurred me yesterday: try
deleting all the .pyc files included in the "Croizat" distribution
archive, then go to the /source sub-folder of the installation folder
and run the Croizat.py file from there. The Python interpreter will
recompile the code and rebuild the .pyc files in the source folder.
Maybe this will help. Anyway, let me know the results.

With warmest regards,

---------- Forwarded message ----------
From: Lionel Roubeyrie <lroubeyrie@...1068...>
Date: 2009/1/22
Subject: Re: [Matplotlib-users] Fwd: Croizat on Mac OS X
To: Matplotlib Users <matplotlib-users@lists.sourceforge.net>

Maybe a backend problem, since your soft is based on wx and the user
uses Tk :
...

Using fontManager instance from /Users/nick/.matplotlib/fontManager.cache
backend TkAgg version 8.4
Traceback (most recent call last):
File "Croizat.py", line 71, in <module>
   Croizat = Application(0)

...
--
Lionel Roubeyrie
charg� d'�tudes
LIMAIR - La Surveillance de l'Air en Limousin
http://www.limair.asso.fr

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

This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--

Nicholas J. Matzke
Ph.D. student, Graduate Student Researcher
Huelsenbeck Lab
Center for Theoretical Evolutionary Genomics
4151 VLSB (Valley Life Sciences Building)
Department of Integrative Biology
University of California, Berkeley

Lab websites:
http://ib.berkeley.edu/people/lab_detail.php?lab=54
http://fisher.berkeley.edu/cteg/hlab.html
Dept. personal page: http://ib.berkeley.edu/people/students/person_detail.php?person=370
Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
Lab phone: 510-643-6299
Dept. fax: 510-643-6264
Cell phone: 510-301-0179
Email: matzke@...1016...

Mailing address:
Department of Integrative Biology
3060 VLSB #3140
Berkeley, CA 94720-3140

-----------------------------------------------------
"[W]hen people thought the earth was flat, they were wrong. When people thought the earth was spherical, they were wrong. But if you think that thinking the earth is spherical is just as wrong as thinking the earth is flat, then your view is wronger than both of them put together."

Isaac Asimov (1989). "The Relativity of Wrong." The Skeptical Inquirer, 14(1), 35-44. Fall 1989.
http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm

Croizat is calling pylab here via basemap, which is a bug. Croizat is
a wx app, and should never import pylab or pyplot. This is happening
somewhere in basemap, most likely a call to basemap is not passing in
an axes or figure instance in. When basemap gets a default axes
instance of None, it imports pyplot and creates its own. I have no
idea why this is happening on one platform and not another for
Croizat, but this is where the bug is occurring most likely.

A good way to track this down is to remove matplotlib/pyplot.py from
site-packages and rerun. The stack trace should show you which
Croizat/basemap call is triggering the import, and you can fix it
there. The fix you are trying is dangerous, unsupported, and likely
to fail in unpredicatable ways.

JDH

···

On Mon, Jan 26, 2009 at 2:14 PM, Nick Matzke <matzke@...1016...> wrote:

Hi Mauro,

Update:

1. I went to the place that threw an error in the basemap code:

>>
"/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py",

>> line 2501, in set_axes_limits
>> figManager.canvas.draw()
>> AttributeError: 'NoneType' object has no attribute 'canvas'
>>
>>

The code is:

============
        # force draw if in interactive mode.
        if is_interactive():
            figManager = _pylab_helpers.Gcf.get_active()
            figManager.canvas.draw()

So, I changed "interactive = true" to "interactive = false" in my
matplotlibrc file.

John Hunter wrote:

···

On Mon, Jan 26, 2009 at 2:14 PM, Nick Matzke <matzke@...1016...> wrote:
  

Hi Mauro,

Update:

1. I went to the place that threw an error in the basemap code:

>>
"/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/python2.5/site-packages/basemap-0.99.1.0001-py2.5-macosx-10.3-fat.egg/mpl_toolkits/basemap/__init__.py",

>> line 2501, in set_axes_limits
>> figManager.canvas.draw()
>> AttributeError: 'NoneType' object has no attribute 'canvas'
>>

The code is:

============
        # force draw if in interactive mode.
        if is_interactive():
            figManager = _pylab_helpers.Gcf.get_active()
            figManager.canvas.draw()

So, I changed "interactive = true" to "interactive = false" in my
matplotlibrc file.
    
Croizat is calling pylab here via basemap, which is a bug. Croizat is
a wx app, and should never import pylab or pyplot. This is happening
somewhere in basemap, most likely a call to basemap is not passing in
an axes or figure instance in. When basemap gets a default axes
instance of None, it imports pyplot and creates its own. I have no
idea why this is happening on one platform and not another for
Croizat, but this is where the bug is occurring most likely.

A good way to track this down is to remove matplotlib/pyplot.py from
site-packages and rerun. The stack trace should show you which
Croizat/basemap call is triggering the import, and you can fix it
there. The fix you are trying is dangerous, unsupported, and likely
to fail in unpredicatable ways.

JDH

I think the problem could be solved by having the app explicity set interactive to false (using matplotlib.interactive(False)), instead of letting the users matplotlibrc determine it. From a cursory look at the code, it looks like the app is not letting basemap create it's own axes instance with pyplot. It's just that if basemap finds that is_interactive is True, it will use pyplot for force the canvas to be drawn.

-Jeff

----
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg