Error when importing PyMC3 3.9.3


I’ve been using PyMC3 3.9.3 for a while. But very recently (within a week) I am not able to import the package because of below error. Is it a bug?


Downgrading xarray to an earlier version (0.15.1) fixed the error. So it seems the latest xarray version (0.16.1) installed automatically when installing pymc3==3.9.3 is not compatible.

import pymc3
Traceback (most recent call last):
File “”, line 1, in
File “/home/ubuntu/.local/lib/python3.6/site-packages/pymc3/”, line 41, in
from .distributions import *
File “/home/ubuntu/.local/lib/python3.6/site-packages/pymc3/distributions/”, line 15, in
from . import timeseries
File “/home/ubuntu/.local/lib/python3.6/site-packages/pymc3/distributions/”, line 22, in
from pymc3.util import get_variable_name
File “/home/ubuntu/.local/lib/python3.6/site-packages/pymc3/”, line 20, in
import arviz
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/”, line 28, in
from .data import *
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/data/”, line 2, in
from .inference_data import InferenceData, concat
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/data/”, line 15, in
from …utils import _subset_list, HtmlTemplate
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/”, line 670, in
class HtmlTemplate:
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/”, line 696, in HtmlTemplate
css_template = f" {xr.core.formatting_html.CSS_STYLE}{specific_style} "
AttributeError: module ‘xarray.core.formatting_html’ has no attribute ‘CSS_STYLE’

1 Like

This issue is due to ArviZ using part of the private xarray API for the html repr of InferenceData objects. This has already been fixed in so there are now 2 ways to solve the issue

  • Use latest PyMC3 and ArviZ releases (should also work with older releases) and xarray<=0.16, its only xarray 0.16.1 the one that is incompatible
  • Update to xarray 0.16.1 and to ArviZ’s development version. A new ArviZ release will be available soon after which the latest release will already work with xarray 0.16.1

ArviZ 0.10.0 is already available in pypi and conda forge, everything works again with xarray 0.16.1