I'm trying to load /usr/share/matplotlib/sample_data/goog.npy
:
datafile = matplotlib.cbook.get_sample_data('goog.npy', asfileobj=False)
np.load(datafile)
It's fine in Python 2.7, but raises an exception in Python 3.4:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd4 in position 1: ordinal not in range(128)
I assume it has something to do with bytes/str/unicode
inconsistency between Python 2 and 3, but have no idea how to get through.
Question:
- How to load a
.npy
file (NumPy data) from Python 2 in Python 3?