Error when importing PyMC3 3.9.3

Hi,

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?

Thanks,
Yurong

Update:
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/init.py”, line 41, in
from .distributions import *
File “/home/ubuntu/.local/lib/python3.6/site-packages/pymc3/distributions/init.py”, line 15, in
from . import timeseries
File “/home/ubuntu/.local/lib/python3.6/site-packages/pymc3/distributions/timeseries.py”, line 22, in
from pymc3.util import get_variable_name
File “/home/ubuntu/.local/lib/python3.6/site-packages/pymc3/util.py”, line 20, in
import arviz
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/init.py”, line 28, in
from .data import *
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/data/init.py”, line 2, in
from .inference_data import InferenceData, concat
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/data/inference_data.py”, line 15, in
from …utils import _subset_list, HtmlTemplate
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/utils.py”, line 670, in
class HtmlTemplate:
File “/home/ubuntu/.local/lib/python3.6/site-packages/arviz/utils.py”, 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 https://github.com/arviz-devs/arviz/pull/1389 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
7 Likes

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

4 Likes