Search code examples
pythonstatsmodels

Error While Importing statsmodels.api "AttributeError: module 'scipy' has no attribute '_lib'"


when I import statsmodels.api as sm it gives the error import statsmodels.api as sm
But if I only import statsmodels as sm then it does not give any error

but a few days ago import statsmodels.api as sm was also working
and I also tried pip install statsmodels --force-reinstall --user But it did not fix the problem

And also my python file is not named statsmodels.py or statsmodels.ipynb


Solution

  • after I reloaded vs code after running pip install statsmodels --force-reinstall --user it fixed my problem