id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 550067372,MDU6SXNzdWU1NTAwNjczNzI=,3696,AttributeError: cannot set attribute '_accessors' on a 'DataArray' object.,8020943,closed,0,,,6,2020-01-15T09:31:18Z,2020-01-16T12:09:52Z,2020-01-15T15:18:05Z,NONE,,,,"#### MCVE Code Sample Create two `conda` environments: - `conda create --name xr140 python xarray==0.14.0 ipython -y` - `conda create --name xr141 python xarray==0.14.1 ipython -y` The following works if you run all of it within the same environment. However, if you store it with `xarray=0.14.0`, and load it with `xarray=0.14.1`, then it fails. ```python import shelve import xarray as xr import numpy as np data = xr.DataArray(data=np.arange(10), dims=[""test""]) # Store data with shelve.open('test') as db: db['data'] = data # Load data with shelve.open('test') as db: newdata = db['data'] np.allclose(data, newdata) ``` #### Expected Output One should be able to load the pickle no matter what the version of `xarray` is. #### Problem Description Storing with `xarray=0.14.0` and trying to load with `xarray=0.14.1` results in the following output: ``` --------------------------------------------------------------------------- KeyError Traceback (most recent call last) ~/anaconda3/envs/xarray141/lib/python3.8/shelve.py in __getitem__(self, key) 110 try: --> 111 value = self.cache[key] 112 except KeyError: KeyError: 'data' During handling of the above exception, another exception occurred: AttributeError Traceback (most recent call last) ~/anaconda3/envs/xarray141/lib/python3.8/site-packages/xarray/core/common.py in __setattr__(self, name, value) 261 try: --> 262 object.__setattr__(self, name, value) 263 except AttributeError as e: AttributeError: 'DataArray' object has no attribute '_accessors' The above exception was the direct cause of the following exception: AttributeError Traceback (most recent call last) in 5 # Load data 6 with shelve.open('test') as db: ----> 7 newdata = db['data'] 8 ~/anaconda3/envs/xarray141/lib/python3.8/shelve.py in __getitem__(self, key) 112 except KeyError: 113 f = BytesIO(self.dict[key.encode(self.keyencoding)]) --> 114 value = Unpickler(f).load() 115 if self.writeback: 116 self.cache[key] = value ~/anaconda3/envs/xarray141/lib/python3.8/site-packages/xarray/core/common.py in __setattr__(self, name, value) 268 ): 269 raise --> 270 raise AttributeError( 271 ""cannot set attribute %r on a %r object. Use __setitem__ style"" 272 ""assignment (e.g., `ds['name'] = ...`) instead of assigning variables."" AttributeError: cannot set attribute '_accessors' on a 'DataArray' object. Use __setitem__ styleassignment (e.g., `ds['name'] = ...`) instead of assigning variables. ``` #### Output of ``xr.show_versions()`` The `xr.show_versions()` for the two environments are identical, except for the `xarray` versions.
INSTALLED VERSIONS ------------------ commit: None python: 3.8.1 (default, Jan 8 2020, 22:29:32) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.15.0-74-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: None libnetcdf: None xarray: 0.14.0 OR 0.14.1 pandas: 0.25.3 numpy: 1.17.4 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None setuptools: 44.0.0.post20200106 pip: 19.3.1 conda: None pytest: None IPython: 7.11.1 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3696/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue