AttributeError: module 'arviz' has no attribute 'geweke'

Hi all, I have been using PyMC for ~3 weeks now without issue, however have recently run into some problems when trying to import the package (note, this was not happening as of last week). More specifically, when trying to import pymc3, I get the following error “AttributeError: module ‘arviz’ has no attribute ‘geweke’”

I have tried reinstalling PyMC3 as well as Arviz with no luck, so I am hoping somebody here can help me out, thanks in advance!

Full Traceback:
> AttributeError Traceback (most recent call last)

in
1 import arviz as az
----> 2 import pymc3 as pm
3 import theano
4 from statsmodels.formula.api import glm as glm_sm
5 import statsmodels.api as sm

/opt/conda/envs/Python-3.6-WMLCE/lib/python3.6/site-packages/pymc3/init.py in
62 from .sampling import *
63 from .smc import *
—> 64 from .stats import *
65 from .step_methods import *
66 from .tests import test

/opt/conda/envs/Python-3.6-WMLCE/lib/python3.6/site-packages/pymc3/stats/init.py in
45 compare = map_args(az.compare)
46 ess = map_args(az.ess)
—> 47 geweke = map_args(az.geweke)
48 hpd = map_args(az.hpd)
49 loo = map_args(az.loo)

AttributeError: module ‘arviz’ has no attribute ‘geweke’

Package Versions:
Python = 3.6.10
PyMC3 = 3.10.0
Arviz = 0.11.2

I have been facing the same problem for few days. Are you also using Google colab? And Have you found the solution?. Please let me know too.

Not sure if you are on colab or not, but the root issue is 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.

If you are not on colab however, I strongly recommend using python>=3.8 and updating to both latest ArviZ and PyMC3

3 Likes

Now running into a new issue when using ArviZ = 0.11.0

ImportError Traceback (most recent call last)
in
1 import arviz as az
----> 2 import pymc3 as pm
3 import theano
4 from statsmodels.formula.api import glm as glm_sm
5 import statsmodels.api as sm

/opt/conda/envs/Python-3.6-WMLCE/lib/python3.6/site-packages/pymc3/init.py in
37
38
—> 39 __set_compiler_flags()
40
41 from . import gp, ode, sampling

/opt/conda/envs/Python-3.6-WMLCE/lib/python3.6/site-packages/pymc3/init.py in __set_compiler_flags()
31 def __set_compiler_flags():
32 # Workarounds for Theano compiler problems on various platforms
—> 33 import theano
34
35 current = theano.config.gcc.cxxflags

/opt/conda/envs/Python-3.6-WMLCE/lib/python3.6/site-packages/theano/init.py in
108 object2, utils)
109
→ 110 from theano.compile import (
111 SymbolicInput, In,
112 SymbolicOutput, Out,

/opt/conda/envs/Python-3.6-WMLCE/lib/python3.6/site-packages/theano/compile/init.py in
26 from theano.compile.builders import *
27
—> 28 from theano.compile.function import function, function_dump

/opt/conda/envs/Python-3.6-WMLCE/lib/python3.6/site-packages/theano/compile/function/init.py in
5 from collections import OrderedDict
6
----> 7 from theano.compile.function.pfunc import pfunc
8 from theano.compile.function.types import orig_function
9

/opt/conda/envs/Python-3.6-WMLCE/lib/python3.6/site-packages/theano/compile/function/pfunc.py in
8
9 from theano import config
—> 10 from theano.compile.function.types import UnusedInputError, orig_function
11 from theano.compile.io import In, Out
12 from theano.compile.profiling import ProfileStats

/opt/conda/envs/Python-3.6-WMLCE/lib/python3.6/site-packages/theano/compile/function/types.py in
21 from theano.gof import graph
22 from theano.gof.op import ops_with_inner_function
—> 23 from theano.gof.toolbox import is_same_graph
24
25

ImportError: cannot import name ‘is_same_graph’

Guessing this is a further problem with Python version, now with Theano. I am working on Watson Studio and cannot upgrade my python very easily, so will have to be using older package versions unfortunately :confused:

Check that pymc3 and theano versions are compatible, here are pymc3 3.10 requirements: pymc3/requirements.txt at v3.10.0 · pymc-devs/pymc3 · GitHub

1 Like

Alright, I am able to import pymc using the following python and package versions

Python: 3.6.10
PyMC3: 3.10.0
Theano: 1.0.11
ArviZ: 0.11.0

Ideally I upgrade to a better Python version but this will have to work for now. Appreciate the help @OriolAbril

3 Likes

Great, glad I could help

I have the same error on a freshly installed 3.6 virtual environment.

You need to either upgrade to a newer python version or use the older package versions as I listed above, hope that helps

I have just began to have a similar error in Anaconda. I’m not sure if that helps or confuses the issue?

Python=3.8.8
PyMC3=3.8
ArviZ=0.11.2

The message was:

import pymc3 as pm

File “C:\Anaconda\envs\py38\lib\site-packages\pymc3_init_.py”, line 13, in
from .stats import *

File “C:\Anaconda\envs\py38\lib\site-packages\pymc3\stats_init_.py”, line 32, in
geweke = map_args(az.geweke)

AttributeError: module ‘arviz’ has no attribute ‘geweke’

1 Like

ArviZ 0.11.2 is not compatible with pymc3 3.8, either upgrade pymc3 to the latest version or downgrade arviz to 0.11.0

Muchas gracias

I ran into this problem when I updated my conda environment today. I was able to resolve it with

conda install -c conda-forge arviz=0.11.0
6 Likes

That command worked for me. Thank you very much!

really thanks it’s working

pymc3=3.9.3; arviz=0.11.2. Same problem. Solution suggested by Allen worked. Might be good to sort this out in the package repo.

This is already sorted out in the newer releases (in fact, this was never broken with the latest releases of the two packages, we already have extensive testing for that, but it’s not possible to test all old versions) and we can’t go back to already released versions of the packages to edit their requirements. I don’t think there is anything else we can do, if there were please let us know and/or volunteer and help us do it.

Fresh conda environment → conda install pymc3 → immediately get the above problem. Solution suggested by Allen did NOT work for me (instead my kernel dies as soon as I try to import pymc3). python=3.8.8; pymc3=3.8; arviz = 0.11.0 (after downgrade)

conda create -n myenv -c conda-forge
conda activate myenv
conda install pymc3 -c conda-forge

Remember to use conda-forge channel.

2 Likes

That did the trick - thank you @ahartikainen !