AttributeError: module 'arviz' has no attribute 'geweke' in Google Colab

It’s been a few days since Pymc3 not working in Google Colab. It’s strange it was working well a few days back. Please help!!

# Install packages that are not installed in colab

      import google.colab
      IN_COLAB = True
  IN_COLAB = False
    !pip install pymc3==3.9
    !pip install --upgrade daft
    !pip install --upgrade theano

while importing Pymc3

import pymc3 as pm

It Throws an error saying

AttributeError :Traceback (most recent call last)
<ipython-input-2-713791f6eaaf> in <module>()
      4 import numpy as np
      5 import pandas as pd
----> 6 import pymc3 as pm
      7 import scipy.stats as stats
      8 from scipy.optimize import curve_fit

/usr/local/lib/python3.6/dist-packages/pymc3/stats/ in <module>()
     44 compare = map_args(
     45 ess = map_args(az.ess)
---> 46 geweke = map_args(az.geweke)
     47 hpd = map_args(az.hpd)
     48 loo = map_args(az.loo)

AttributeError: module 'arviz' has no attribute 'geweke

Hi, the root issue is probably colab still running on python 3.6. Latest PyMC3 versions (like latest numpy, scipy, matplotlib…) dropped python 3.6 support some months ago, however it looks like we forgot to explicitly drop py3.6 support on ArviZ which results on latest ArviZ being install which is not compatible with pymc3 3.10. Forcing ArviZ<=0.10 (maybe even <=0.11.0) should fix the issue.

1 Like

Oh, and you can track this issue to see when will colab update its python and you’ll be able to use the latest versions of the libraries in the pydata stack: Python 3.8.7+ (3.9.1+) support (and Ubuntu 20.04) · Issue #1422 · googlecolab/colabtools · GitHub


Thanks; it works for now!!

1 Like

Thank you for explaining. How do you set colab for installing ArviZ<=0.10?

Using !pip install arviz==0.10.0 in a code cell should do the trick


I’m encountering this issue in a DataBricks notebook running python 3.7.6 and pymc3 3.9.3. Adding !pip install arviz==0.10.0 to a cell does fix the problem. My specs are not consistent with the python 3.6 hypothesis, so wondering if there is another issue or explanation.

ArviZ and PyMC3 versions are tied together. Changes in ArviZ affect PyMC3 when it tries to run convergence checks and changes in PyMC3 affect ArviZ, if you look at the pymc3 requirements file, you’ll see how each release increases the required ArviZ version: latest pymc3 versions won’t work with old ArviZ versions and viceversa.

In python3.6 the default situation is now latest ArviZ being installed (as it still supports py3.6) but not latest pymc3 (as it does not support py3.6 anymore) which are not compatible.

In your case, even though you are on python 3.7, you have pymc3 3.9.3 but if you encountered this error, it means that you had latest ArviZ. The situation is basically the same, the only difference is in how have old pymc3 plus latest ArviZ come to coexist.

Sadly we can’t go and update the requirements of released versions retroactively to prevent that from happening.

We are also working on better aligning versions between the packages (see for example Port InferenceData conversion code to pymc3 codebase by OriolAbril · Pull Request #4489 · pymc-devs/pymc3 · GitHub), but we don’t have the resources to support multiple versions of either of the packages. We will work on integrating latest pymc3 with latest ArviZ, aligning their releases as much as possible and make releases of either of them if needed to fix any issues (see for example ArviZ 0.8.1-0.8.3 releases), but as a general rule you should not expect any PyMC3-ArviZ combination to work.

… duh why didn’t I think of that. Thank you - that helped. Wait it’s May 5 2021 … i thought this was going to be fixed? LOL Anyways, thanks for your help!