obspy has a bug?

Hello,

I have a Mac, OS 10.10 (Yosemite) running Python 3.4.4

When I try to read in a SEGY file using a simple python script, t.py:

import signal
import sys
from obspy import read, Trace, Stream, UTCDateTime
from obspy.core import AttribDict
from obspy.segy.segy import SEGYTraceHeader, SEGYBinaryFileHeader
from obspy.segy.core import readSEGY
import numpy as np
fin=readSEGY('/Users/goldman/dimond15.11.segy’)

I get the error message:

Traceback (most recent call last):
  File "t.py", line 9, in <module>
    fin=readSEGY('/Users/goldman/dimond15.11.segy')
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/obspy/segy/core.py", line 245, in readSEGY
    second=second)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/obspy/core/utcdatetime.py", line 330, in __init__
    dt = datetime.datetime(*args, **kwargs)

Does this mean there is a bug in readSEGY?

Note that if I try to run t.py in an anaconda environment:
cd ~/anaconda/bin
sh
conda create -n myenv
conda install -n myenv -c -obspy obspy
source ./activate myenv
python t.py

Then I get a lot of inscrutable error messages:

Traceback (most recent call last):
  File "t.py", line 3, in <module>
    from obspy import read, Trace, Stream, UTCDateTime
  File "/Users/goldman/anaconda/envs/myenv/lib/python3.4/site-packages/obspy-0.10.2-py3.4-macosx-10.5-x86_64.egg/obspy/__init__.py", line 47, in <module>
    read.__doc__ % make_format_plugin_table("waveform", "read", numspaces=4)
  File "/Users/goldman/anaconda/envs/myenv/lib/python3.4/site-packages/obspy-0.10.2-py3.4-macosx-10.5-x86_64.egg/obspy/core/util/base.py", line 476, in make_format_plugin_table
    "obspy.plugin.%s.%s" % (group, name), method)
  File "/Users/goldman/anaconda/envs/myenv/lib/python3.4/site-packages/setuptools-19.1.1-py3.4.egg/pkg_resources/__init__.py", line 568, in load_entry_point
  File "/Users/goldman/anaconda/envs/myenv/lib/python3.4/site-packages/setuptools-19.1.1-py3.4.egg/pkg_resources/__init__.py", line 2720, in load_entry_point
  File "/Users/goldman/anaconda/envs/myenv/lib/python3.4/site-packages/setuptools-19.1.1-py3.4.egg/pkg_resources/__init__.py", line 2379, in load
  File "/Users/goldman/anaconda/envs/myenv/lib/python3.4/site-packages/setuptools-19.1.1-py3.4.egg/pkg_resources/__init__.py", line 2396, in require
  File "/Users/goldman/anaconda/envs/myenv/lib/python3.4/site-packages/setuptools-19.1.1-py3.4.egg/pkg_resources/__init__.py", line 849, in resolve
pkg_resources.DistributionNotFound: The 'nose>=0.11.1' distribution was not found and is required by matplotlib

So I am at a loss

Mark Goldman
U.S. Geological Survey
345 Middlefield Rd, MS 977
Menlo Park, CA 94025
goldman@usgs.gov
650-329-5496

I think part of the problem is this:
pkg_resources.DistributionNotFound: The 'nose>=0.11.1' distribution was not found and is required by matplotlib
You need to install nose 0.11.1 or later. I had something similar on windows but don't remember the details.

Randy

Hi Mark,

Randy is right, there's a package missing in your anaconda install. A
simple `conda install nose` should do the trick.
Python tracebacks can be confusing at the start, just always make sure
to read from the last line backwards in general.
(Seems the matplotlib package has an error there in the packaging, it
should specify that it needs nose and then anaconda would have pulled it
in automatically. Can you please do a `conda list matplotlib` for
version numbers, so we can report this upstream?)

That problem you have with reading SEGY I was unable to reproduce, can
you send the file (if it's big or restricted by private mail), so I/we
can have a look? Version number of obspy in your global Python would be
interesting, too (e.g. `python -c "import obspy;
print(obspy.__version__)"`).

Sorry you're having problems to get started, that shouldn't be the case,
you might have run into a very unlucky combination of version numbers
there. I'm sure we can sort this out soon, though.

cheers,
Tobias

Mark,
In obspy isn't it UTCDateTime vs datetime for the syntax? dt = datetime.datetime(*args, **kwargs)

Mark,

A second look at this. Is your error output complete?
I can get similar :

c:\miniconda2\lib\site-packages\obspy-0.10.2-py2.7-win32.egg\obspy\core\utcdatet
ime.pyc in __init__(self, *args, **kwargs)
    328 kwargs['second'] = int(_sec)
    329 args = args[0:5]
--> 330 dt = datetime.datetime(*args, **kwargs)
    331 self._fromDateTime(dt)
    332

ValueError: second must be in 0..59

OR:
c:\miniconda2\lib\site-packages\obspy-0.10.2-py2.7-win32.egg\obspy\core\utcdatet
ime.pyc in __init__(self, *args, **kwargs)
    328 kwargs['second'] = int(_sec)
    329 args = args[0:5]
--> 330 dt = datetime.datetime(*args, **kwargs)
    331 self._fromDateTime(dt)
    332

TypeError: integer argument expected, got float

the code at the error point is checking for an integer value for seconds. Your file may be feeding an bad value for second into the starttime.

Randy

Hello,

I did forget to include the last line of output in my previous email,
concerning an error when running obspy in on a Mac OS 10.10 (Yosemite):

Traceback (most recent call last):
  File "t.py", line 9, in <module>
    fin=readSEGY('/Users/goldman/dimond15.11.segy')
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/obspy/segy/core.py", line 245, in readSEGY
    second=second)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/obspy/core/utcdatetime.py", line 330, in __init__
    dt = datetime.datetime(*args, **kwargs)
TypeError: Required argument 'month' (pos 2) not found

However, in Macports I was able to install py-nose, and now I can run the python code without error

Also, typing “conda install nose” fixed the problem in the Anaconda environment as well

Thanks for all your help

Mark