pythonpython-2.7numpydata-acquisition

Reading data from data acquisition unit (measurement computing)


I have a data acquisition unit (USB-2408 from Measurement Computing) and am trying to write Python code to display that data in as close to real-time as I can, but obviously that's limited, so I'll take what I can get. I ran across a man that has already done this, almost.

So I found his PyUL site and tried some of the example code he has (copied and pasted it straight into a .py file and threw it in my relevant directory. When I call the code through cmd (...\Python27\Lib\site-packages\sciypy>python example1.py) I get an error code :

C:\Program Files (x86)\Python27\Lib\site-packages\scipy>
Traceback (most recent call last):
  File "daq-scipy1.py", line 3, in <module>
    import UniversalLibrary as UL
  File "C:\Program Files (x86)\Python27\lib\site-packaget__.py", line 36, in <module>
    from UniversalLibrary import *
  File "C:\Program Files (x86)\Python27\lib\site-packagersalLibrary.py", line 53, in <module>
    import numpy
  File "C:\Program Files (x86)\Python27\lib\site-packages\numpy\__init__.py", line 168, in <module>
    from . import add_newdocs
  File "C:\Program Files (x86)\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Program Files (x86)\Python27\lib\site-packages\numpy\lib\__init__.py", line 22, in <module>
    from .npyio import *
  File "C:\Program Files (x86)\Python27\lib\site-packages\numpy\lib\npyio.py", line 4, in <module>
    from . import format
  File "C:\Program Files (x86)\Python27\lib\site-packages\numpy\lib\format.py", line 141, in <module>
    import io
  File "C:\Program Files (x86)\Python27\Lib\site-packages\scipy\io\__init__.py" line 85, in <module>
    from .matlab import loadmat, savemat, whosmat, byteo
  File "C:\Program Files (x86)\Python27\Lib\site-packages\scipy\io\matlab\__init__.py", line 13, in <module>
    from .mio import loadmat, savemat, whosmat
  File "C:\Program Files (x86)\Python27\Lib\site-packages\scipy\io\matlab\mio.py", line 10, in <module>
    from scipy.lib.six import string_types
  File "C:\Program Files (x86)\Python27\lib\site-packages\scipy\__init__.py", line 77, in <module>
    from numpy import oldnumeric
  File "C:\Program Files (x86)\Python27\lib\site-packages\numpy\oldnumeric\__init__.py", line 24, in <module>
    from .compat import *
  File "C:\Program Files (x86)\Python27\lib\site-package\numpy\oldnumeric\compat.py", line 14, in <module>
    from . import functions
  File "C:\Program Files (x86)\Python27\lib\site-packages\numpy\oldnumeric\functions.py", line 9, in <module>
    from .typeconv import convtypecode, convtypecode2
  File "C:\Program Files (x86)\Python27\lib\site-packages\numpy\oldnumeric\typeconv.py", line 7, in <module>
    oldtype2dtype = {'1': np.dtype(np.byte),
AttributeError: 'module' object has no attribute 'dtype'

Is there a file or module maybe that I haven't installed that would keep this from running or similar solution/workaround? I ran this code just to see if I could handle the data coming from the unit in a way separate to the software they provide with the unit. If thereis a better way, please inform me. I have already tried pySerial, pywinusb or d2xx and others like pywin32 to no avail. The unit is listed in device manager these days as a completely new device class: DAS Component, older units used to be under USB Human Interface Devices.

Relevant Info: Python2.7 (32-bit) on Windows 8


Solution

  • I haven't reached the bottom of this problem yet, but it looks like a problem with numpy because Python cannot find a dtype attribute in np, which is how numpy is imported into the file oldnumeric/typeconv.py within the numpy distribution.

    I suspect one of:

    1. A corrupted numpy distribution (in which case you would be best to re-install numpy), or
    2. A name space conflict of some sort.

    numpy has test code for dtype (it is in ../numpy/core/tests/test_dtype.py) so you could run the numpy test suite and see if it throws an error relating to dtype.

    The other thing I've noticed is that the PyUL code uses the old Numeric package, which may perhaps be conflicting with numpy