'i cant import "statsmodels.api" for the reason of "there's no module of Scipy.integrate sub module"

I'm using anaconda Jupyter notebook and trina import the below.

import os import pandas as pd import numpy as np import scipy import statsmodels.api as sm

But here's the Error.

ModuleNotFoundError                       Traceback (most recent call last) <ipython-input-1-89daf53fdc43> in <module>
      3 import numpy as np
      4 import scipy
----> 5 import statsmodels.api as sm ~\Anaconda3\lib\site-packages\statsmodels\api.py in <module>
      5 from . import tools
      6 from .tools.tools import add_constant, categorical
----> 7 from . import regression
      8 from .regression.linear_model import OLS, GLS, WLS, GLSAR
      9 from .regression.recursive_ls import RecursiveLS ~\Anaconda3\lib\site-packages\statsmodels\regression\__init__.py in <module>
----> 1 from .linear_model import yule_walker
      2 
      3 from statsmodels.tools._testing import PytestTester
      4 
      5 __all__ = ['yule_walker', 'test'] ~\Anaconda3\lib\site-packages\statsmodels\regression\linear_model.py in <module>
     38 import numpy as np
     39 from scipy.linalg import toeplitz
---> 40 from scipy import stats
     41 from scipy import optimize
     42  ~\Anaconda3\lib\site-packages\scipy\stats\__init__.py in <module>
    365 from __future__ import division, print_function, absolute_import
    366 
--> 367 from .stats import *
    368 from .distributions import *
    369 from .morestats import * ~\Anaconda3\lib\site-packages\scipy\stats\stats.py in <module>
    171 from scipy._lib._util import _lazywhere
    172 import scipy.special as special
--> 173 from . import distributions
    174 from . import mstats_basic
    175 from ._stats_mstats_common import _find_repeats, linregress, theilslopes, siegelslopes ~\Anaconda3\lib\site-packages\scipy\stats\distributions.py in <module>
      8 from __future__ import division, print_function, absolute_import
      9 
---> 10 from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
     11                                     rv_frozen)
     12  ~\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py in <module>
     25 
     26 # for functions of continuous distributions (e.g. moments, entropy, cdf)
---> 27 from scipy import integrate
     28 
     29 # to approximate the pdf of a continuous distribution given its cdf ~\Anaconda3\lib\site-packages\scipy\integrate\__init__.py in <module>
     87 from __future__ import division, print_function, absolute_import
     88 
---> 89 from .quadrature import *
     90 from .odepack import *
     91 from .quadpack import * ModuleNotFoundError: No module named 'scipy.integrate.quadrature

so i download using Cmd. (pip install scipy) Also, i already checked the anaconda navigator weather i download the scipy module, but it alrealy did.

how can i import this module?



Solution 1:[1]

pip and conda adds symlink at different locations, which can cause some confusing mix-ups.

Thus, try to have all your packages managed by one OR the other should fix the issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tony