【发布时间】:2019-06-12 14:31:59
【问题描述】:
我正在使用带有 Python 3.6.8 的 Anaconda 环境,使用 conda create -n temp pandas pytables h5py python=3.6.8 创建。当我尝试读取.h5 文件时:
f = pd.read_hdf(filename, key)
我得到一个ValueError 异常:
Traceback (most recent call last):
File "read_data.py", line 6, in <module>
f = pd.read_hdf(filename, key)
File "/home/fauzanzaid/anaconda3/envs/temp/lib/python3.6/site-packages/pandas/io/pytables.py", line 394, in read_hdf
return store.select(key, auto_close=auto_close, **kwargs)
File "/home/fauzanzaid/anaconda3/envs/temp/lib/python3.6/site-packages/pandas/io/pytables.py", line 741, in select
return it.get_result()
File "/home/fauzanzaid/anaconda3/envs/temp/lib/python3.6/site-packages/pandas/io/pytables.py", line 1483, in get_result
results = self.func(self.start, self.stop, where)
File "/home/fauzanzaid/anaconda3/envs/temp/lib/python3.6/site-packages/pandas/io/pytables.py", line 734, in func
columns=columns)
File "/home/fauzanzaid/anaconda3/envs/temp/lib/python3.6/site-packages/pandas/io/pytables.py", line 2928, in read
ax = self.read_index('axis%d' % i, start=_start, stop=_stop)
File "/home/fauzanzaid/anaconda3/envs/temp/lib/python3.6/site-packages/pandas/io/pytables.py", line 2523, in read_index
_, index = self.read_index_node(getattr(self.group, key), **kwargs)
File "/home/fauzanzaid/anaconda3/envs/temp/lib/python3.6/site-packages/pandas/io/pytables.py", line 2621, in read_index_node
data = node[start:stop]
File "/home/fauzanzaid/anaconda3/envs/temp/lib/python3.6/site-packages/tables/vlarray.py", line 685, in __getitem__
return self.read(start, stop, step)
File "/home/fauzanzaid/anaconda3/envs/temp/lib/python3.6/site-packages/tables/vlarray.py", line 821, in read
listarr = self._read_array(start, stop, step)
File "tables/hdf5extension.pyx", line 2155, in tables.hdf5extension.VLArray._read_array
ValueError: cannot set WRITEABLE flag to True of this array
如果我使用带有 python 3.7 或 3.5 的环境,这个问题就会消失。但是,我需要使用 python 3.6。
我该如何解决这个错误?
【问题讨论】:
-
这是两天内第二个关于
pd.read_hdf()退出并出现此错误的问题:tables/hdf5extension.pyx in tables.hdf5extension.VLArray._read_array() ValueError: cannot set WRITEABLE flag to True of this array查看此问题:link 我建议直接联系 Pandas 开发人员。 -
如果它适用于 Python 3.5 环境,您是否尝试过指定在这种情况下安装但使用 Python 3.6 的
pandas、pytables和h5py的版本号? IE。conda create -n temp pandas=x.x pytables=y.y h5py=z.z python=3.6(其中 x.x、y.y 和 z.z 是相关的版本号,obvs)。 -
三者中,只有
h5py不同,3.5 为2.8.0,3.6+ 为2.9.0。降级h5py不起作用。我还尝试将numpy从1.15.4降级为1.15.2,但也没有用。我想我应该提交一份错误报告。
标签: pandas anaconda python-3.6 ubuntu-18.04 pytables