Posts Tagged ‘ debugging

GDAL and GMT – Success (this time for real)

Well.  I honestly am not sure what fixed my problems, but the good news is, the GMT install went smoothly, and I now have a fully functional GMT + GDAL install.  And I’m ready for MB-System!

So I basically sat down tonight, for the first time in ages, prepared to dig into GMT/GDAL again, armed with advice from both Kurt and Monica on how I might fix things. (or at least begin a fruitful investigation into why it wasn’t working). So to get back up to speed, I wanted to display the errors that I’d been seeing before. The problems would arise when I tried installing GMT using the command

sudo sh install_gmt GMTparam.txt

Where GMTparam.txt is the input file that I carefully prepared on the GMT download site. I was previously getting all sorts of errors telling me that all of my GDAL functions were undefined. I ran the GMT installer again, and, lo and behold, it just worked. I suspect it had something to do with me rebooting the system. Is it possible that I hadn’t rebooted after my last GDAL re-install? Maybe. And maybe it needed to reboot to recognize the changes? I’m not sure. But I’m happy that I can finally move on. It feels good.

Debugging Python code

Reading through the third chapter of my bazillion page Python book, I came across a discussion of debuggers.  I’m used to the way Matlab works when debugging – putting little stop buttons on certain lines, and stepping through the code if I need to.  Since my code always has bugs in it, I thought learning about debuggers would be important.  I was surprised to see that the first two recommended ‘debugging’ methods in my book were:  (1) Do nothing!  Just read the error statements, and go to that line in your code and fix it.  (2) Print statements – this lets you print out a message or a variable value, generally enough to tell you what you need to know.  These first two are all I’ve ever used before, and seemed to be fine for me.  Also, the author of the book says those are the only ones he uses.  And he wrote the bazillion page book, so he must know what he’s talking about.  I will stick with these two, but mention the other three just for interest’s sake:  (3) IDE GUI debuggers like IDLE, (4) pdb, a command line debugger that is contained in Python’s standard library, and (5) more specific debugging option such as winpdb.

This information can be found on page 67 of Learning Python.

So, once again, the KISS (keep it simple, stupid) method prevails.  I love it.