Req: Python 2.x incompatibility with MatPlotlab & SciTools

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dave067
    New Member
    • Sep 2010
    • 17

    Req: Python 2.x incompatibility with MatPlotlab & SciTools

    Hi folks

    I am teaching myself Python by working through Hans Petter Langtangen's excellent book "Primer on Scientific Programming in Python".

    The exercises in chapter 4 of the book require the student to use Python with the freely downloadable tools MatplotLib and SciTools to plot graphs of mathematical functions.

    Despite downloading and installing numerous different versions of Python 2.x, MatPlotLib and SciTools, I am unable to find a combination which will work together without crashing.

    I'm currently using a Windows XP laptop with:
    Python 2.6.6
    IDLE 2.6.6
    MatplotLib 0.99,3 win32 Py2.6
    Scitools from scipy-0.80-win32-superpack-python 2.6

    When I try to run a simple script to test the plotting functions, I get the error messages attached below.

    I don't want to use Python 3, as there still seem to be some teething problems with this, and many of the modules that I've already written or need to use are not compatible with Python 3.x.

    I've emailed the author, but have not yet had a reply.
    I wondered if anyone else on the Bytes forum had encountered this problem and could tell me a compatible combination of versions of Python 2.x, MatPlotLib and Scitools; and the URL of sites where I can download these.

    Many thanks in anticipation


    Dave
    (UK)

    =============== ==============
    Code:
    from scitools.std import *
    
    def f(t):
        return t**2*exp(-t**2)
    
    t = linspace(0,3,51)
    y = zeros(len(t))
    for i in xrange(len(t)):
        y[i] = f(t[i])
    
    plot(t,y)
    =============== =============== =

    >>>
    scitools.easyvi z backend is matplotlib

    Traceback (most recent call last):
    File "C:\Python\Dave _Book Exercises\4_3_2 Plot test_DW.py", line 11, in <module>
    plot(t,y)
    File "C:\Python26\li b\site-packages\scitoo ls\easyviz\comm on.py", line 3060, in plot
    self._replot()
    File "C:\Python26\li b\site-packages\scitoo ls\easyviz\matp lotlib_.py", line 906, in _replot
    self._g.draw()
    File "C:\Python26\li b\site-packages\matplo tlib\pyplot.py" , line 352, in draw
    get_current_fig _manager().canv as.draw()
    File "C:\Python26\li b\site-packages\matplo tlib\backends\b ackend_tkagg.py ", line 215, in draw
    FigureCanvasAgg .draw(self)
    File "C:\Python26\li b\site-packages\matplo tlib\backends\b ackend_agg.py", line 314, in draw
    self.figure.dra w(self.renderer )
    File "C:\Python26\li b\site-packages\matplo tlib\artist.py" , line 46, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
    File "C:\Python26\li b\site-packages\matplo tlib\figure.py" , line 773, in draw
    for a in self.axes: a.draw(renderer )
    File "C:\Python26\li b\site-packages\matplo tlib\artist.py" , line 46, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
    File "C:\Python26\li b\site-packages\matplo tlib\axes.py", line 1735, in draw
    a.draw(renderer )
    File "C:\Python26\li b\site-packages\matplo tlib\artist.py" , line 46, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
    File "C:\Python26\li b\site-packages\matplo tlib\axis.py", line 742, in draw
    tick.draw(rende rer)
    File "C:\Python26\li b\site-packages\matplo tlib\artist.py" , line 46, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
    File "C:\Python26\li b\site-packages\matplo tlib\axis.py", line 196, in draw
    self.label1.dra w(renderer)
    File "C:\Python26\li b\site-packages\matplo tlib\text.py", line 518, in draw
    bbox, info = self._get_layou t(renderer)
    File "C:\Python26\li b\site-packages\matplo tlib\text.py", line 280, in _get_layout
    clean_line, self._fontprope rties, ismath=ismath)
    File "C:\Python26\li b\site-packages\matplo tlib\backends\b ackend_agg.py", line 148, in get_text_width_ height_descent
    texmanager = self.get_texman ager()
    File "C:\Python26\li b\site-packages\matplo tlib\backend_ba ses.py", line 374, in get_texmanager
    from matplotlib.texm anager import TexManager
    File "C:\Python26\li b\site-packages\matplo tlib\texmanager .py", line 72, in <module>
    class TexManager:
    File "C:\Python26\li b\site-packages\matplo tlib\texmanager .py", line 94, in TexManager
    _dvipng_hack_al pha = dvipng_hack_alp ha()
    File "C:\Python26\li b\site-packages\matplo tlib\texmanager .py", line 68, in dvipng_hack_alp ha
    raise RuntimeError('C ould not obtain dvipng version')
    RuntimeError: Could not obtain dvipng version
    >>>
  • ethana
    New Member
    • Nov 2006
    • 1

    #2
    I agree with Dave067 that Langtangen's "A Primer on Scientific Programming with Python" is an excellent textbook. I have had good luck in running his example programs. Like Dave067 I use Python 2.6.6 and IDLE 2.6.6. I use an HP desktop computer with Vista Home Premium Edition.

    The installation file that I used for matplotlib is
    matplotlib-1.0.1.win32-py2.6.exe
    available on the web at


    The installation file that I used for SciTools is
    SciTools-0.8.win32.exe
    available on the web at


    A Google search on the names of these installation files shows many other URLs where they can be downloaded.

    Hope this helps.

    Comment

    Working...