Adventures in ObsPy

I finally got around to trying out ObsPy… well, okay, I am still trying to figure out how to install it properly. Finally made some headway though. I followed the instructions on the ObsPy installation page.  I thought everything was going smoothly.  For starters, I had all of the dependencies – most importantly Python, SciPy, NumPy, and Matplotlib.  I also had the Easy_install package already from when I was installing Mercurial.

The installations all seemed to go just fine, I was getting messages telling me it was all good.  But then it just didn’t work.  I opened up iPython, tried to give it a whirl, and it just didn’t recognize those packages at all.  Turns out the default installation location was not actually in the Python path.  It sounds like it should be pretty easy to fix, but it took me a long time to figure it out.

So, normally, if you want to import from a Python library, you would use something like this:

from numpy import *

But when I tried importing obspy.core, like this:

from obspy.core import read

it couldn’t find the library. After much searching, I finally figured out how to add to my python path. First, say in iPython, import sys, and check the path:

import sys
sys.path

This will list what’s in the path. So for me, it was:

['',
'/sw/bin',
'/sw/lib/python26.zip',
'/sw/lib/python2.6',
'/sw/lib/python2.6/plat-darwin',
'/sw/lib/python2.6/plat-mac',
'/sw/lib/python2.6/plat-mac/lib-scriptpackages',
'/sw/lib/python2.6/lib-tk',
'/sw/lib/python2.6/lib-old',
'/sw/lib/python2.6/lib-dynload',
'/sw/lib/python2.6/site-packages',
'/sw/lib/python2.6/site-packages/Numeric',
'/sw/lib/python2.6/site-packages/gtk-2.0',
'/sw/lib/python2.6/site-packages/IPython/Extensions',
u'/Users/michellejw/.ipython']

To add to that path, I just used:

sys.path.append('Library/Python/2.6/site-packages/packagefolderthatIwanted')

And it worked! Although I’m still not sure how to change it permanently. But until I figure that out, at least I can play with ObsPy.

One thought on “Adventures in ObsPy

Leave a Reply

Your email address will not be published. Required fields are marked *