By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,096 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,096 IT Pros & Developers. It's quick & easy.

Req: Python 2.x incompatibility with MatPlotlab & SciTools

P: 17
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)

=============================
Expand|Select|Wrap|Line Numbers
  1. from scitools.std import *
  2.  
  3. def f(t):
  4.     return t**2*exp(-t**2)
  5.  
  6. t = linspace(0,3,51)
  7. y = zeros(len(t))
  8. for i in xrange(len(t)):
  9.     y[i] = f(t[i])
  10.  
  11. plot(t,y)
  12.  
  13.  
===============================

>>>
scitools.easyviz 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\lib\site-packages\scitools\easyviz\common.py", line 3060, in plot
self._replot()
File "C:\Python26\lib\site-packages\scitools\easyviz\matplotlib_.py", line 906, in _replot
self._g.draw()
File "C:\Python26\lib\site-packages\matplotlib\pyplot.py", line 352, in draw
get_current_fig_manager().canvas.draw()
File "C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 215, in draw
FigureCanvasAgg.draw(self)
File "C:\Python26\lib\site-packages\matplotlib\backends\backend_agg.py", line 314, in draw
self.figure.draw(self.renderer)
File "C:\Python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 773, in draw
for a in self.axes: a.draw(renderer)
File "C:\Python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python26\lib\site-packages\matplotlib\axes.py", line 1735, in draw
a.draw(renderer)
File "C:\Python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python26\lib\site-packages\matplotlib\axis.py", line 742, in draw
tick.draw(renderer)
File "C:\Python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python26\lib\site-packages\matplotlib\axis.py", line 196, in draw
self.label1.draw(renderer)
File "C:\Python26\lib\site-packages\matplotlib\text.py", line 518, in draw
bbox, info = self._get_layout(renderer)
File "C:\Python26\lib\site-packages\matplotlib\text.py", line 280, in _get_layout
clean_line, self._fontproperties, ismath=ismath)
File "C:\Python26\lib\site-packages\matplotlib\backends\backend_agg.py", line 148, in get_text_width_height_descent
texmanager = self.get_texmanager()
File "C:\Python26\lib\site-packages\matplotlib\backend_bases.py", line 374, in get_texmanager
from matplotlib.texmanager import TexManager
File "C:\Python26\lib\site-packages\matplotlib\texmanager.py", line 72, in <module>
class TexManager:
File "C:\Python26\lib\site-packages\matplotlib\texmanager.py", line 94, in TexManager
_dvipng_hack_alpha = dvipng_hack_alpha()
File "C:\Python26\lib\site-packages\matplotlib\texmanager.py", line 68, in dvipng_hack_alpha
raise RuntimeError('Could not obtain dvipng version')
RuntimeError: Could not obtain dvipng version
>>>
Jan 12 '11 #1
Share this Question
Share on Google+
1 Reply


P: 1
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
http://www.lfd.uci.edu/~gohlke/pythonlibs/

The installation file that I used for SciTools is
SciTools-0.8.win32.exe
available on the web at
http://code.google.com/p/scitools/downloads/detail?n

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

Hope this helps.
May 1 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.