Skip to content

unable to import statsmodels.api #5572

Closed

Description

@saurabhkumar27

I am getting below error


ModuleNotFoundError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\statsmodels\compat\pandas.py in ()
52 try:
---> 53 import pandas.tseries.tools as datetools
54 import pandas.tseries.frequencies as frequencies

ModuleNotFoundError: No module named 'pandas.tseries.tools'

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
in ()
----> 1 import statsmodels.api as sm

~\Anaconda3\lib\site-packages\statsmodels\api.py in ()
5 from . import regression
6 from .regression.linear_model import OLS, GLS, WLS, GLSAR
----> 7 from .regression.recursive_ls import RecursiveLS
8 from .regression.quantile_regression import QuantReg
9 from .regression.mixed_linear_model import MixedLM

~\Anaconda3\lib\site-packages\statsmodels\regression\recursive_ls.py in ()
14 from statsmodels.regression.linear_model import OLS
15 from statsmodels.tools.data import _is_using_pandas
---> 16 from statsmodels.tsa.statespace.mlemodel import (
17 MLEModel, MLEResults, MLEResultsWrapper)
18 from statsmodels.tools.tools import Bunch

~\Anaconda3\lib\site-packages\statsmodels\tsa\statespace\mlemodel.py in ()
15 from .kalman_filter import (KalmanFilter, FilterResults, INVERT_UNIVARIATE,
16 SOLVE_LU)
---> 17 import statsmodels.tsa.base.tsa_model as tsbase
18 import statsmodels.base.wrapper as wrap
19 from statsmodels.tools.numdiff import (_get_epsilon, approx_hess_cs,

~\Anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py in ()
1 from statsmodels.compat.python import lrange, long
----> 2 from statsmodels.compat.pandas import is_numeric_dtype
3
4 import datetime
5

~\Anaconda3\lib\site-packages\statsmodels\compat\pandas.py in ()
54 import pandas.tseries.frequencies as frequencies
55 except ImportError:
---> 56 from pandas.core import datetools
57 frequencies = datetools

ImportError: cannot import name 'datetools'

Activity

  1. lwsdegithub commented on Apr 24, 2019

    @lwsdegithub

    so what?
    you can just reinstall the pandas

  2. saurabhkumar27 commented on Apr 24, 2019

    @saurabhkumar27
    Author

    reinstalling pandas doesn't sort my error, as it says to install datetools

  3. jvanneck commented on May 2, 2019

    @jvanneck

    Me too, it happened to me after I moved to the latest version of pandas (pandas==0.24.2), I was on 0.23.2 before I think and it was working.

  4. bashtage commented on May 2, 2019

    @bashtage
    Member

    You are probably running 0.9, which is quite old. If you upgrade to statsmodels master this is fixed (assuming you have a compiler, pip install git+https://github.com/statsmodels/statsmodels will install the latest master). If you cannot upgrade to the latest statsmodels, you will need to use an older version of pandas.

  5. bashtage commented on May 9, 2019

    @bashtage
    Member

    Closing. Will be fixed when the next release is out.

  6. akhiljamdar commented on Apr 3, 2020

    @akhiljamdar

    getting error while import stdecompose library ///--

    ImportError Traceback (most recent call last)
    in ()
    ----> 1 from stldecompose import decompose, forecast

    ~/anaconda3/lib/python3.6/site-packages/stldecompose/init.py in ()
    ----> 1 from .stl import decompose, forecast

    ~/anaconda3/lib/python3.6/site-packages/stldecompose/stl.py in ()
    4 from statsmodels.tsa.seasonal import DecomposeResult
    5 from statsmodels.tsa.filters._utils import _maybe_get_pandas_wrapper_freq
    ----> 6 import statsmodels.api as sm
    7
    8

    ~/anaconda3/lib/python3.6/site-packages/statsmodels/api.py in ()
    9 from . import regression
    10 from .regression.linear_model import OLS, GLS, WLS, GLSAR
    ---> 11 from .regression.recursive_ls import RecursiveLS
    12 from .regression.quantile_regression import QuantReg
    13 from .regression.mixed_linear_model import MixedLM

    ~/anaconda3/lib/python3.6/site-packages/statsmodels/regression/recursive_ls.py in ()
    9 import pandas as pd
    10
    ---> 11 from statsmodels.compat.pandas import Appender
    12
    13 from statsmodels.tools.data import _is_using_pandas

    ImportError: cannot import name 'Appender'

  7. bashtage commented on Apr 3, 2020

    @bashtage
    Member

    What pandas do you have installed? Have a look at closed issues. This has appeared in another thread.

  8. hafez-ahmad commented on Apr 7, 2020

    @hafez-ahmad

    File "", line 7, in
    from statsmodels.tsa.api import VAR, DynamicVAR

    ImportError: cannot import name 'DynamicVAR' from 'statsmodels.tsa.api' (C:\Users\hafez\anaconda3\lib\site-packages\statsmodels\tsa\api.py)

  9. bashtage commented on Apr 7, 2020

    @bashtage
    Member

    Please upgrade to the latest release. DynamicVAR isn't in it.

  10. cocolilian commented on May 26, 2020

    @cocolilian

    Hello,I followed this method(pip install git+https://github.com/statsmodels/statsmodels.git) and have been waited for a long time(like hours). I wonder how long should I wait before it is done?
    Below are what is going on on my screen:
    Collecting git+https://github.com/statsmodels/statsmodels.git
    Cloning https://github.com/statsmodels/statsmodels.git to /tmp/pip-req-build-1pwouxyr
    Running command git clone -q https://github.com/statsmodels/statsmodels.git /tmp/pip-req-build-1pwouxyr

  11. bashtage commented on May 26, 2020

    @bashtage
    Member

    Assuming you have a reasonable internet connection and a relatively modern computer, it should all finish in a couple of minutes.

  12. cocolilian commented on May 26, 2020

    @cocolilian

    Thank you.But it seems not work for me,I waited for some time.There is another question now,it signaled 'cannot import name 'factorial' from 'scipy.misc' (/opt/conda/lib/python3.7/site-packages/scipy/misc/init.py)' when I entered 'from statsmodels.formula.api import ols'.The package is already installed.And if I enter 'import statsmodels',no warnings appear.How to do with it?

  13. bashtage commented on May 26, 2020

    @bashtage
    Member

    You have very old statsmodels that is not supported. You should be using Python 3 (probably 3.7 or 3.8) to get a working copy of statsmodels.

  14. bashtage commented on May 26, 2020

    @bashtage
    Member

    If you are not sure what you are doing, please use Anaconda.

  15. cocolilian commented on May 26, 2020

    @cocolilian

    I am working on a JupyterLab link which offered by a contest, and I think I can hardly copy data from it .Perhaps I am not getting used to it.When using JupyterLab, there is no 'cmd' to 'pip packages' easily.

  16. bashtage commented on May 26, 2020

    @bashtage
    Member

    You need to get support from the people running the competition.

  17. cocolilian commented on May 26, 2020

    @cocolilian

    Yes,I will.Thanks for your help!

  18. vinit2shah commented on Sep 16, 2020

    @vinit2shah

    I have statsmodels version 0.13.0 using pip install git+https://github.com/statsmodels/statsmodels. I have Visuall C++ version 14.0.
    But still I can't import statsmodels.api.

    THis is what I get:

    ImportError Traceback (most recent call last)
    in ()
    1 import numpy as np
    2 from numba import njit
    ----> 3 import statsmodels.api as sm
    4 import matplotlib.pyplot as plt
    5 get_ipython().magic('matplotlib inline')

    ~\Anaconda3\lib\site-packages\statsmodels\api.py in ()
    9 from . import regression
    10 from .regression.linear_model import OLS, GLS, WLS, GLSAR
    ---> 11 from .regression.recursive_ls import RecursiveLS
    12 from .regression.quantile_regression import QuantReg
    13 from .regression.mixed_linear_model import MixedLM

    ~\Anaconda3\lib\site-packages\statsmodels\regression\recursive_ls.py in ()
    12
    13 from statsmodels.tools.data import _is_using_pandas
    ---> 14 from statsmodels.tsa.statespace.mlemodel import (
    15 MLEModel, MLEResults, MLEResultsWrapper, PredictionResults,
    16 PredictionResultsWrapper)

    ~\Anaconda3\lib\site-packages\statsmodels\tsa\statespace\mlemodel.py in ()
    34 from .kalman_filter import INVERT_UNIVARIATE, SOLVE_LU, MEMORY_CONSERVE
    35 from .initialization import Initialization
    ---> 36 from .tools import prepare_exog, concat
    37
    38

    ImportError: cannot import name 'prepare_exog'

  19. bashtage commented on Sep 16, 2020

    @bashtage
    Member

    Can you install 0.12.0 correctly?

  20. vinit2shah commented on Sep 16, 2020

    @vinit2shah

    Sorry, issue solved. forgot to restart the kernel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions