Search code examples
pythonpython-3.ximporterrorstatsmodelspython-3.9

Python 3.9 in Statsmodel ImportError: cannot import name 'Literal' from 'statsmodels.compat.python'


I cannot manage to import ARIMA model from statsmodels without encountering this error:

This is how the import is:

from statsmodels.tsa.arima.model import ARIMA

This is the error:

ImportError: cannot import name 'Literal' from 'statsmodels.compat.python' (C:\Users\HP\Anaconda3\lib\site-packages\statsmodels\compat\python.py)

I have already tried to uninstall, re-install and update it, but that does not change. Please help me solve the error.


Solution

  • I found the solution:

    Importing ARIMA from arima_model instead of arima.model:

    from statsmodels.tsa.arima_model import ARIMA
    

    https://www.statsmodels.org/0.8.0/generated/statsmodels.tsa.arima_model.ARIMA.html