Skip to content

HDF5 files not compatible between python 2 and 3 ? #4260

Closed
@hadim

Description

@hadim

I have a problem loading a h5 file from python 3 to python 2 and vice versa. I can't post the code which generate h5 file because is part of a big project. I'll try to upload h5 file directly later.

Here is the error when I load FROM python 3.3 an h5 file created BY python 2.7:

Traceback (most recent call last):
  File "/home/hadim/local/virtualenvs/st3/src/master/build/lib.linux-x86_64-3.3/pandas/core/index.py", line 1539, in _get_level_number
    level = self.names.index(level)
ValueError: 'side' is not in list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 49, in <module>
    meta = SimuIO().read(results_file)
  File "../kt_simul/io/simuio.py", line 210, in read
    KD.spbL.traj = spbs.xs('A', level='side').values.T[0]
  File "/home/hadim/local/virtualenvs/st3/src/master/build/lib.linux-x86_64-3.3/pandas/core/frame.py", line 2335, in xs
    loc, new_ax = labels.get_loc_level(key, level=level)
  File "/home/hadim/local/virtualenvs/st3/src/master/build/lib.linux-x86_64-3.3/pandas/core/index.py", line 2322, in get_loc_level
    level = self._get_level_number(level)
  File "/home/hadim/local/virtualenvs/st3/src/master/build/lib.linux-x86_64-3.3/pandas/core/index.py", line 1542, in _get_level_number
    raise Exception('Level %s not found' % str(level))
Exception: Level side not found
Closing remaining open files: simu.h5... done 

Here is the error when I load FROM python 2.7 an h5 file created BY python 3.3:

Traceback (most recent call last):
  File "main.py", line 49, in <module>
    meta = SimuIO().read(results_file)
  File "/home/hadim/.phd/dev/kt_simul/kt_simul/io/simuio.py", line 197, in read
    param_root = build_tree(store['params'])
  File "/home/hadim/local/virtualenvs/st/src/master/pandas/io/pytables.py", line 289, in __getitem__
    return self.get(key)
  File "/home/hadim/local/virtualenvs/st/src/master/pandas/io/pytables.py", line 422, in get
    return self._read_group(group)
  File "/home/hadim/local/virtualenvs/st/src/master/pandas/io/pytables.py", line 930, in _read_group
    return s.read(**kwargs)
  File "/home/hadim/local/virtualenvs/st/src/master/pandas/io/pytables.py", line 2194, in read
    values = self.read_array('block%d_values' % i)
  File "/home/hadim/local/virtualenvs/st/src/master/pandas/io/pytables.py", line 1776, in read_array
    data = node[:]
  File "/home/hadim/local/virtualenvs/st/local/lib/python2.7/site-packages/tables/vlarray.py", line 661, in __getitem__
    return self.read(start, stop, step)
  File "/home/hadim/local/virtualenvs/st/local/lib/python2.7/site-packages/tables/vlarray.py", line 801, in read
    outlistarr = [atom.fromarray(arr) for arr in listarr]
  File "/home/hadim/local/virtualenvs/st/local/lib/python2.7/site-packages/tables/atom.py", line 1151, in fromarray
    return cPickle.loads(array.tostring())
ValueError: unsupported pickle protocol: 3
Closing remaining open files: simu.h5... done

Version command run:

import sys
print(sys.version)
import numpy
print(numpy.__version__)
import tables
print(tables.__version__)
import pandas
print (pandas.__version__)

Python 3 shell:

3.3.1 (default, Apr 17 2013, 22:30:32) 
[GCC 4.7.3]
1.7.1
3.0.0
0.12.0.dev-404dfab

Python 2 shell:

2.7.4 (default, Apr  9 2013, 18:05:19) 
[GCC 4.7.3]
1.7.1
3.0.0
0.12.0.dev-4c2d050

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions