ImportError: cannot import name 'gaussian' from 'scipy.signal'

I’m trying to import arviz, pymc and pymc_bart packages but I got an error message showing below:

ImportError                               Traceback (most recent call last)
Cell In[9], line 6
      3 import statsmodels.api as sm 
      4 from sklearn.metrics import mean_squared_error
----> 6 import arviz as az
      7 import matplotlib.pyplot as plt
      8 import numpy as np

File /opt/conda/lib/python3.9/site-packages/arviz/
     30 _log = Logger("arviz")
     33 from .data import *
---> 34 from .plots import *
     35 from .plots.backends import *
     36 from .stats import *

File /opt/conda/lib/python3.9/site-packages/arviz/plots/
      1 """Plotting functions."""
----> 2 from .autocorrplot import plot_autocorr
      3 from .bpvplot import plot_bpv
      4 from .bfplot import plot_bf

File /opt/conda/lib/python3.9/site-packages/arviz/plots/
      5 from ..rcparams import rcParams
      6 from ..utils import _var_names
----> 7 from .plot_utils import default_grid, filter_plotters_list, get_plotting_function
     10 def plot_autocorr(
     11     data,
     12     var_names=None,
     24     show=None,
     25 ):
     26     r"""Bar plot of the autocorrelation function (ACF) for a sequence of data.
     28     The ACF plots are helpful as a convergence diagnostic for posteriors from MCMC
    117         >>> az.plot_autocorr(data, var_names=['mu', 'tau'], max_lag=200, combined=True)
    118     """

File /opt/conda/lib/python3.9/site-packages/arviz/plots/
     11 from scipy.interpolate import CubicSpline
     14 from ..rcparams import rcParams
---> 15 from ..stats.density_utils import kde
     16 from ..stats import hdi
     18 KwargSpec = Dict[str, Any]

File /opt/conda/lib/python3.9/site-packages/arviz/stats/
      1 # pylint: disable=wildcard-import
      2 """Statistical tests and diagnostics for ArviZ."""
----> 3 from .density_utils import *
      4 from .diagnostics import *
      5 from .stats import *

File /opt/conda/lib/python3.9/site-packages/arviz/stats/
      6 from scipy.fftpack import fft
      7 from scipy.optimize import brentq
----> 8 from scipy.signal import convolve, convolve2d, gaussian  # pylint: disable=no-name-in-module
      9 from scipy.sparse import coo_matrix
     10 from scipy.special import ive  # pylint: disable=no-name-in-module

ImportError: cannot import name 'gaussian' from 'scipy.signal' (/opt/conda/lib/python3.9/site-packages/scipy/signal/

I’ve tried to use from scipy.signal.window import gaussian but it still doesn’t work. So I cannot run the whole code because of this.

Does anyone know how to solve the problem? Currently I’m using Python version 3.9.18.

Thank you in advance.

It’s a current issue with the latest scipy and arviz. There should be a release soon on the arviz side that will fix it. In the meantime you can downgrade scipy < 1.13

Thank you. It works now with scipy==1.10.0

It also works with scipy 1.12.0

this is very helpful, I had the same issue and now it is fixed. Thank you

ArviZ 0.18.0 is already on pypi, so this should no longer happen if using latest ArviZ, it will be on conda forge shortly.

1 Like