Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: cannot set WRITEABLE flag to True of this array #24839

Closed
macd2 opened this issue Jan 19, 2019 · 16 comments · Fixed by #36683
Closed

ValueError: cannot set WRITEABLE flag to True of this array #24839

macd2 opened this issue Jan 19, 2019 · 16 comments · Fixed by #36683
Assignees
Labels
Bug Dependencies Required and optional dependencies IO HDF5 read_hdf, HDFStore
Milestone

Comments

@macd2
Copy link

macd2 commented Jan 19, 2019

will need to revert the xfail decorator in: #25517 when this is fixed

Code Sample, a copy-pastable example if possible

Im getting all of a sudden this Error, any idea?

# Your code here
 input_df = pd.read_hdf(path_or_buf='x.hdf5',key='/x',mode='r')

Problem description

Traceback :

Traceback (most recent call last):
  File "...", line 115, in <module>
    input_df = pd.read_hdf(path_or_buf='x.hdf5',key='/x',mode='r')
  File "/usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py", line 394, in read_hdf
    return store.select(key, auto_close=auto_close, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py", line 741, in select
    return it.get_result()
  File "/usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py", line 1483, in get_result
    results = self.func(self.start, self.stop, where)
  File "/usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py", line 734, in func
    columns=columns)
  File "/usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py", line 2937, in read
    start=_start, stop=_stop)
  File "/usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py", line 2489, in read_array
    ret = node[0][start:stop]
  File "/usr/local/lib/python3.6/dist-packages/tables/vlarray.py", line 681, in __getitem__
    return self.read(start, stop, step)[0]
  File "/usr/local/lib/python3.6/dist-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
```
@gfyoung gfyoung added the IO HDF5 read_hdf, HDFStore label Jan 20, 2019
@gfyoung
Copy link
Member

gfyoung commented Jan 20, 2019

@macd2 : Thanks for reporting this! A couple of things:

  • In the issue, could you provide your environment information from pandas.show_versions ?
  • Assuming you can, do you mind sharing the file that triggers this error?

Im getting all of a sudden this Error, any idea?

  • It sounds like this was working for you on a previous versions of pandas . When did this code last work for you? What version are you using now (related to the first question)?

cc @jreback

@gfyoung gfyoung added the Needs Info Clarification about behavior needed to assess issue label Jan 20, 2019
@vvvlc
Copy link

vvvlc commented Jan 20, 2019

When using numpy=1.16.0 I get this error, when I downgrade numpy=1.15.4 problem is gone

@macd2
Copy link
Author

macd2 commented Jan 21, 2019

@gfyoung Sure here is the Versions:

'dependencies': 
{'pandas': '0.23.4', 'pytest': '3.4.0', 'pip': '18.1', 'setuptools': '40.6.3', 'Cython': '0.29.3', 'numpy': '1.16.0', 'scipy': '1.2.0', 'pyarrow': None, 'xarray': None, 'IPython': '6.5.0', 'sphinx': None, 'patsy': '0.5.0', 'dateutil': '2.7.5', 'pytz': '2018.7', 'blosc': None, 'bottleneck': '1.2.1', 'tables': '3.4.4', 'numexpr': '2.6.8', 'feather': None, 'matplotlib': '3.0.2', 'openpyxl': '2.5.12', 'xlrd': '1.1.0', 'xlwt': '1.3.0', 'xlsxwriter': '0.7.3', 'lxml': '4.1.1', 'bs4': '4.4.1', 'html5lib': '1.0b8', 'sqlalchemy': '1.2.15', 'pymysql': '0.9.2', 'psycopg2': '2.7.6.1 (dt dec pq3 ext lo64)', 'jinja2': '2.10', 's3fs': None, 'fastparquet': None, 'pandas_gbq': None, 'pandas_datareader': '0.7.0'}

unfortunately i can not share the file but i think the issues indeed comes from numpy as @vvvlc said here is an other issue on their git:

nipy/nibabel#697

PS: just downgraded to numpy=1.15.4 and indeed it resolves the issue

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Jan 21, 2019 via email

@mikkokotila
Copy link

mikkokotila commented Jan 23, 2019

For me pip install numpy==1.15.4 also resolves this issue.

@TomAugspurger this issue comes up on Google on top (at least for me it did) and it seems that the remedy is simple, so maybe it's enough to just wait for an upstream fix. Really great that you would ask :)

@swinman
Copy link

swinman commented Jan 23, 2019

pip3 install numpy==1.15.4 also solved for me..

However, when I downgraded numpy i kept getting this error ImportError: No module named 'numpy.core._multiarray_umath'. Finally figured out it was happening because I stored the .h5 file with numpy 1.16 installed and it wouldn't reopen with the downgraded numpy...

@dev72
Copy link

dev72 commented Feb 2, 2019

you can avoid the error:
ValueError: cannot set WRITEABLE flag to True of this array
passing format='table' to HDFStore.append or HDFStore.put when you save data with pandas.

This will likely solve your problem, tested with pandas 0.24 and numpy 1.16+

@macd2
Copy link
Author

macd2 commented Feb 2, 2019

@dev72
ok but how about old HDF files that already exist?

@dev72
Copy link

dev72 commented Feb 2, 2019

I think the best way to read old hdf files is to downgrade your pandas+numpy version, read all data and write it in a new hdf store with format='table'.
Then it should work with newer numpy and pandas versions.

@macd2
Copy link
Author

macd2 commented Feb 3, 2019

@dev72 yes right im at the same point, but than i rather stick with the downgrade until this is properly fixed

@swyxio
Copy link

swyxio commented Feb 3, 2019

yes same came from google, thanks for filing this issue @macd2

@esvhd
Copy link

esvhd commented Feb 23, 2019

So after chasing around a few issues submitted at numpy and PyTables this post by @avalentino would suggest this issue is fixed in PyTables master but not in a release yet.

PyTables/PyTables#719 (comment)

Has anyone tried using PyTables master w/ numpy >= 0.16?

@ghost
Copy link

ghost commented Mar 12, 2019

I got it to work using this

HDF5_DIR={HDF5_PATH} pip install -e git+https://github.com/PyTables/PyTables@492ee2f#egg=tables
pip install numpy==1.16.0

Make sure cython and hdf5 are installed.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Mar 14, 2019

What versions of pytables and numpy reproduce this? Is it specific to the data?

with

pandas: 0.24.1
numpy: 1.16.2
tables: 3.4.4

this doesn't raise,

In [8]: df = pd.DataFrame({"A": [1, 2]})

In [9]: df.to_hdf('x.hdf5', key='x')

In [10]: pd.read_hdf('x.hdf5', 'x', mode='r')
Out[10]:
   A
0  1
1  2

FYI, pytables 3.5.0 and 3.5.1 are on PyPI with the fix from the pytables side.

@goriccardo
Copy link

Upgrading to pytables 3.5.1 fixes the problem for me also with numpy 1.16.2

slack0 added a commit to iotile/iotile_analytics that referenced this issue Apr 24, 2019
* Updates to analytics-host to support multiple `AnalysisGroup`
- This update modifies `analytics-host` to accept multiple device/device archive
slugs to create `AnalysisGroup` from them

* Fixed `find_analysis_group` to accomodate list input from argparse

* Updated pytables version to 3.5.1 to address incomptability with latest versions
of pandas/numpy (pandas-dev/pandas#24839)

* Added a new template 'multiple_source_info' to get information similar to the
'basic_info' template but for a sequence of device/block slugs input to
`analytics-host`
@mirameshs
Copy link

dealing with tf 2.0.0 need numpy (at least) 1.16.0. downgrading numpy to the previous version won't work on tf 2.0.0

@mroeschke mroeschke added Bug Dependencies Required and optional dependencies and removed Needs Info Clarification about behavior needed to assess issue labels Apr 5, 2020
@alimcmaster1 alimcmaster1 self-assigned this May 1, 2020
fangchenli added a commit to fangchenli/pandas that referenced this issue Sep 27, 2020
@jreback jreback added this to the 1.2 milestone Sep 29, 2020
jreback pushed a commit that referenced this issue Sep 30, 2020
kesmit13 pushed a commit to kesmit13/pandas that referenced this issue Nov 2, 2020
alpae added a commit to DessimozLab/pyoma that referenced this issue Apr 1, 2021
alpae added a commit to DessimozLab/pyoma that referenced this issue Apr 1, 2021
bug reported in related with hdf5 seems to be fixed now:
pandas-dev/pandas#24839

requires pytables>3.5.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dependencies Required and optional dependencies IO HDF5 read_hdf, HDFStore
Projects
None yet
Development

Successfully merging a pull request may close this issue.