[Matplotlib-users] matplotlib with tk? online examples fail...

2009-09-25 Thread Jonathan Tomshine
I'm quite new to python, but am attempting to add basic plotting
functionality to a tk-based GUI application that is run primarily on a
Mac.  My initial attempts at simply calling "plot" or "errorbar" from
within the application resulted in erratic behavior on Python
installed through macports on my machine with OSX 10.5 (the plot
appears, but the window is unresponsive), or no plot whatsoever (on a
friend's Mac with OSX 10.6 and Python, Numpy, and Matplotlib installed
through their "official" .dmg packages).  All versions are current
(Python 2.6.2, Matplotlib 0.99.1.1).

When looking at the matplotlib website, I attempted to run the
following examples:

http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_tk.py
http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_tk2.py

...but these fail on my machine (OSX 10.5):

--

udp009069uds:fret_analysis jshine$ python embedding_in_tk.py
Traceback (most recent call last):
  File "embedding_in_tk.py", line 6, in 
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
NavigationToolbar2TkAgg
  File 
"/Users/jshine/Documents/root/matplotlib/lib/python/matplotlib/backends/backend_tkagg.py",
line 8, in 
import tkagg # Paint image to Tk photo blitter extension
  File 
"/Users/jshine/Documents/root/matplotlib/lib/python/matplotlib/backends/tkagg.py",
line 1, in 
import _tkagg
ImportError: No module named _tkagg
udp009069uds:fret_analysis jshine$

--

For those familiar with macports, I did install it with the "tkinter"
option enabled:

--

dp009069uds:fret_analysis jshine$ port info py26-matplotlib
py26-matplotlib @0.99.1.1 (python, graphics, math)
Variants: cairo, darwin_8, ghostscript, gtk2, latex, qt4,
[+]tkinter, wxpython

Description:  Matplotlib is a pure python plotting library
with the goal of making publication quality plots using a syntax
familiar to matlab
  users. The library uses numpy for handling large
data sets and supports a variety of output backends. This port
provides variants for
  the different GUIs (gtk2, tkinter, wxpython).
Homepage: http://matplotlib.sourceforge.net

Library Dependencies: python26, freetype, libpng, py26-dateutil,
py26-tz, py26-numpy, py26-configobj, py26-pyobjc2, py26-pyobjc2-cocoa
Platforms:darwin
License:  unknown
Maintainers:  [email protected], [email protected]
udp009069uds:fret_analysis jshine$

--

...so at this point, I'm pretty much stuck -- my own application
doesn't work, and I don't have a working example to follow.  I'd
greatly appreciate any pointers!

Thanks,
Jon

-- 
Jonathan Tomshine, PhD
University of California, San Francisco
Genentech Hall
600 16th St.
San Francisco, CA 94158-2140
[email protected]

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib with tk? online examples fail...

2009-09-25 Thread Jonathan Tomshine
You're right!  I almost forgot that I had installed a local copy of
matplotlib a long time ago.  It looks like Python was finding that
copy before it found the "correct" one.  The example appears to work
now.

Thanks again,
-Jon



On Fri, Sep 25, 2009 at 2:14 PM, Jeff Whitaker  wrote:
> Jonathan Tomshine wrote:
>>
>> I'm quite new to python, but am attempting to add basic plotting
>> functionality to a tk-based GUI application that is run primarily on a
>> Mac.  My initial attempts at simply calling "plot" or "errorbar" from
>> within the application resulted in erratic behavior on Python
>> installed through macports on my machine with OSX 10.5 (the plot
>> appears, but the window is unresponsive), or no plot whatsoever (on a
>> friend's Mac with OSX 10.6 and Python, Numpy, and Matplotlib installed
>> through their "official" .dmg packages).  All versions are current
>> (Python 2.6.2, Matplotlib 0.99.1.1).
>>
>> When looking at the matplotlib website, I attempted to run the
>> following examples:
>>
>>
>> http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_tk.py
>>
>> http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_tk2.py
>>
>> ...but these fail on my machine (OSX 10.5):
>>  --
>>
>> udp009069uds:fret_analysis jshine$ python embedding_in_tk.py
>> Traceback (most recent call last):
>>  File "embedding_in_tk.py", line 6, in 
>>    from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
>> NavigationToolbar2TkAgg
>>  File
>> "/Users/jshine/Documents/root/matplotlib/lib/python/matplotlib/backends/backend_tkagg.py",
>> line 8, in 
>>    import tkagg                 # Paint image to Tk photo blitter
>> extension
>>  File
>> "/Users/jshine/Documents/root/matplotlib/lib/python/matplotlib/backends/tkagg.py",
>> line 1, in 
>>    import _tkagg
>> ImportError: No module named _tkagg
>> udp009069uds:fret_analysis jshine$
>>
>
> Jonathan:  You say you're using macports matplotlib, but that traceback does
> not point to a macports directory (which should be in /opt/local).  Perhaps
> you have PYTHONPATH set so you're picking up a local installation of
> matplotlib, which was not built with tkagg support?
>
> -Jeff
>>
>> --
>>
>> For those familiar with macports, I did install it with the "tkinter"
>> option enabled:
>>
>> --
>>
>> dp009069uds:fret_analysis jshine$ port info py26-matplotlib
>> py26-matplotlib @0.99.1.1 (python, graphics, math)
>> Variants:             cairo, darwin_8, ghostscript, gtk2, latex, qt4,
>> [+]tkinter, wxpython
>>
>> Description:          Matplotlib is a pure python plotting library
>> with the goal of making publication quality plots using a syntax
>> familiar to matlab
>>                      users. The library uses numpy for handling large
>> data sets and supports a variety of output backends. This port
>> provides variants for
>>                      the different GUIs (gtk2, tkinter, wxpython).
>> Homepage:             http://matplotlib.sourceforge.net
>>
>> Library Dependencies: python26, freetype, libpng, py26-dateutil,
>> py26-tz, py26-numpy, py26-configobj, py26-pyobjc2, py26-pyobjc2-cocoa
>> Platforms:            darwin
>> License:              unknown
>> Maintainers:          [email protected], [email protected]
>> udp009069uds:fret_analysis jshine$
>>
>> ------
>>
>> ...so at this point, I'm pretty much stuck -- my own application
>> doesn't work, and I don't have a working example to follow.  I'd
>> greatly appreciate any pointers!
>>
>> Thanks,
>> Jon
>>
>>
>
>
> --
> Jeffrey S. Whitaker         Phone  : (303)497-6313
> Meteorologist               FAX    : (303)497-6449
> NOAA/OAR/PSD  R/PSD1        Email  : [email protected]
> 325 Broadway                Office : Skaggs Research Cntr 1D-113
> Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg
>
>



-- 
Jonathan Tomshine, PhD
University of California, San Francisco
Genentech Hall
600 16th St.
San Francisco, CA 94158-2140
[email protected]

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users