2

I am used to using numpy.recfromcsv to load csv files as record arrays in python.

However on my new laptop (MB pro running OS 10.6.6), numpy doesn't seem to recognize recfromcsv as a function (same with genfromtxt or recfromtxt).

>>> import numpy as np
>>> np.recfromcsv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'recfromcsv'

Why would this happen? I have never seen this before and everywhere I look it seems as though recfromcsv (and the rest) should be basic numpy functions. I am working with the native install of python on my machine (Python 2.6.1), and with the version of numpy comes with the Mac OS.

>>> reload(np)
<module 'numpy' from '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/__init__.py'>
Mike Graham
  • 73,987
  • 14
  • 101
  • 130
Tim
  • 21
  • 1
  • 2

1 Answers1

3

If you look at:

np.version.version

you'll see that on mac it's version 1.2.1 (at least on my machine). np.recfromcsv was likely added in a newer release of numpy so that's why you're missing it along with the other methods.

This is a fairly old version of numpy, so you should think about upgrading. And I recommend not messing with the version of python in /usr/bin. Instead install a fresh python build in a different location and then use your .bash_profile to have it place the location of that version ahead of the location of the builtin.

JoshAdel
  • 66,734
  • 27
  • 141
  • 140