Tue, 29 Mar 2011 08:27:52 +0000, Pauli Virtanen wrote: > Tue, 29 Mar 2011 04:16:00 -0400, josef.pktd wrote: >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> File "C:\Programs\Python32\lib\site-packages\numpy\lib\npyio.py", >> line 222, in __getitem__ >> return format.read_array(value) >> File "C:\Programs\Python32\lib\site-packages\numpy\lib\format.py", >> line 449, in read_array >> array = pickle.load(fp) >> UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 6: >> ordinal not in range(128) > [clip] >> Any ideas ? > > There's some open() call that opens the file in text mode rather than in > binary mode, I guess.
Ah, that's not it. The problem is that pickled Numpy arrays are not backward compatible between Python 2 and 3 because of the string vs. unicode change --- the pickle.load() call should specify an encoding eg. pickle.load(fp, encoding='latin1'). This needs to be wrapped in a try-expect block so that it tries to load it with encoding='latin1' if the first attempt fails. -- Pauli Virtanen _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion