Reputation: 45
I am working on Jupyter notebook. My code was working fine but then I installed sklearn for some other project and now my current code stopped working. It suddenly started showing "cannot import name 'logsumexp'" error.
I have tried upgrading sklearn, scikit-learn and statsmodels. There were some suggestions that rolling back to scikit 0.18.02 model would help but that didn't work either. I think this link explains the reason of error ' https://docs.scipy.org/doc/scipy-0.19.1/reference/generated/scipy.misc.logsumexp.html ' but I still don't know how to fix it.
These are my current versions
scikit-learn 0.21.2
scipy 1.3.0
sklearn 0.0
statsmodels 0.9.0
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt
import statsmodels.api as sm
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-9-de89bb760177> in <module>
3 import matplotlib.pyplot as plt
4 from matplotlib import cm
----> 5 from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt
6 import statsmodels.api as sm
~/.local/lib/python3.6/site-packages/statsmodels/tsa/api.py in <module>
23 from .statespace.varmax import VARMAX
24 from .statespace.dynamic_factor import DynamicFactor
---> 25 from .regime_switching.markov_regression import MarkovRegression
26 from .regime_switching.markov_autoregression import MarkovAutoregression
27 from .holtwinters import ExponentialSmoothing, SimpleExpSmoothing, Holt
~/.local/lib/python3.6/site-packages/statsmodels/tsa/regime_switching/markov_regression.py in <module>
11 import statsmodels.base.wrapper as wrap
12
---> 13 from statsmodels.tsa.regime_switching import markov_switching
14
15
~/.local/lib/python3.6/site-packages/statsmodels/tsa/regime_switching/markov_switching.py in <module>
13 from statsmodels.compat.collections import OrderedDict
14
---> 15 from scipy.misc import logsumexp
16 from statsmodels.base.data import PandasData
17 import statsmodels.tsa.base.tsa_model as tsbase
ImportError: cannot import name 'logsumexp'
Upvotes: 1
Views: 6228
Reputation: 3294
I am quoting the answer from a Github issue:
statsmodels 0.9
is not compatible with SciPy 1.3.0
. The current master branch is compatible and the next release will be compatible. The options are to downgrade SciPy, install in a virtual- or conda-env
with SciPy 1.2
, or to install from master branch using the code provided below
pip install --upgrade git+https://github.com/statsmodels/statsmodels
Upvotes: 2
Reputation: 828
Upgrade the packages:
This does not happen on statsmodel 0.10.1
pip install -U scikit-learn scipy statsmodels
If you want a stable environment everytime, I suggest to use conda pinned versions rather than upgrading individual packages.
Upvotes: 0