AttributeError: type object 'Dataset' has no attribute 'unify_chunks'
Raised error when import pyfolio
** example:**
import pyfolio as pf
Please provide the full traceback:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-1977abd82007> in <module>()
----> 1 import pyfolio as pf
/home/ivan/env-zipline/lib/python3.6/site-packages/pyfolio/__init__.py in <module>()
11 from . import perf_attrib
12
---> 13 from .tears import * # noqa
14 from .plotting import * # noqa
15 from ._version import get_versions
/home/ivan/env-zipline/lib/python3.6/site-packages/pyfolio/tears.py in <module>()
36
37 try:
---> 38 from . import bayesian
39 have_bayesian = True
40 except ImportError:
/home/ivan/env-zipline/lib/python3.6/site-packages/pyfolio/bayesian.py in <module>()
22 import matplotlib.pyplot as plt
23
---> 24 import pymc3 as pm
25
26 try:
/home/ivan/env-zipline/lib/python3.6/site-packages/pymc3/__init__.py in <module>()
11 from .model_graph import model_to_graphviz
12 from . import ode
---> 13 from .stats import *
14 from .sampling import *
15 from .step_methods import *
/home/ivan/env-zipline/lib/python3.6/site-packages/pymc3/stats/__init__.py in <module>()
8 import warnings
9
---> 10 import arviz as az
11
12 def map_args(func):
/home/ivan/env-zipline/lib/python3.6/site-packages/arviz/__init__.py in <module>()
14
15
---> 16 from .data import *
17 from .plots import *
18 from .plots import backends
/home/ivan/env-zipline/lib/python3.6/site-packages/arviz/data/__init__.py in <module>()
1 """Code for loading and manipulating data structures."""
2 from .base import CoordSpec, DimSpec, dict_to_dataset, numpy_to_data_array
----> 3 from .converters import convert_to_dataset, convert_to_inference_data
4 from .datasets import clear_data_home, list_datasets, load_arviz_data
5 from .inference_data import InferenceData, concat
/home/ivan/env-zipline/lib/python3.6/site-packages/arviz/data/converters.py in <module>()
4
5 from .base import dict_to_dataset
----> 6 from .inference_data import InferenceData
7 from .io_cmdstan import from_cmdstan
8 from .io_cmdstanpy import from_cmdstanpy
/home/ivan/env-zipline/lib/python3.6/site-packages/arviz/data/inference_data.py in <module>()
50
51
---> 52 class InferenceData:
53 """Container for inference data storage using xarray.
54
/home/ivan/env-zipline/lib/python3.6/site-packages/arviz/data/inference_data.py in InferenceData()
857 sortby = _extend_xr_method(xr.Dataset.sortby)
858 chunk = _extend_xr_method(xr.Dataset.chunk)
--> 859 unify_chunks = _extend_xr_method(xr.Dataset.unify_chunks)
860 load = _extend_xr_method(xr.Dataset.load)
861 compute = _extend_xr_method(xr.Dataset.compute)
AttributeError: type object 'Dataset' has no attribute 'unify_chunks'
Please provide any additional information below:
Versions
- Pyfolio version: pyfolio 0.8.0 py_1 conda-forge
- Python version: 3.6.12 hffdb5ce_0_cpython conda-forge
- Pandas version: 0.22.0 py36_1 conda-forge
- Matplotlib version: 3.3.3 py36he12231b_0 conda-forge
As time goes by, and various packages get updated on conda-forge, more things will break. Here's a workaround until some of these versions are baked in.
Whilst this comment is not a solution, it's certainly a workaround until someone revisits the exact inter-package dependencies.
Using an earlier version of some of the modules seems to fix things arviz v0.7.0 xarray v0.13.0 don't have this issue.
With a LOT of trial and error (probably about 30 virtual environments created), this combination seems to work OK, at least as at Dec 14 2020:
Here's exactly how we install our environments that works with all of our tests:
conda create -n zip36 python=3.6 conda activate zip36 conda install -c conda-forge zipline pyfolio matplotlib-base=3.0.3 xarray=0.13.0 arviz=0.7.0 theano=1.0.3 mkl-service m2w64-toolchain conda install jupyter matplotlib=3.0.3 pip install norgatedata zipline-norgatedata
Note that there are still several patches required to get futures to work correctly, mixed futures/equities bundles, backtesting calendar limits, and some other ugliness/warnings, which we've documented here: https://pypi.org/project/zipline-norgatedata/
Cheers, Richard.
Thank you Richard. This solved the import problem. But unfortunately next problem appears: pyfolio reported about the problem with zipline.assets.