导入 statsmodel.api 时出错。无法导入 specfun

Error importing statsmodel.api. cannot import specfun

我已经为 python 导入了 statsmodel.api 1000 次。刚开始在导入时出现随机错误。有人有这个错误吗?代码如下。

我正在使用 windows,我的 python 是通过 conda 包更新的。

谢谢大家。

`import statsmodels.api as sm`

ImportError                               Traceback (most recent call last)
<ipython-input-50-6030a6549dc0> in <module>()
----> 1 import statsmodels.api as sm

C:\Users\rebortz\Anaconda\lib\site-packages\statsmodels\api.py in <module>()
----> 1 from . import iolib
      2 from . import datasets
      3 from . import tools
      4 from .tools.tools import add_constant, categorical
      5 from . import regression

C:\Users\rebortz\Anaconda\lib\site-packages\statsmodels\iolib\__init__.py in <module>()
----> 1 from .foreign import StataReader, genfromdta, savetxt
      2 from .table import SimpleTable, csv2st
      3 from .smpickle import save_pickle, load_pickle
      4 
      5 from statsmodels import NoseWrapper as Tester

C:\Users\rebortz\Anaconda\lib\site-packages\statsmodels\iolib\foreign.py in <module>()
     18 import numpy as np
     19 from numpy.lib._iotools import _is_string_like, easy_dtype
---> 20 import statsmodels.tools.data as data_util
     21 from pandas import isnull
     22 

C:\Users\rebortz\Anaconda\lib\site-packages\statsmodels\tools\__init__.py in <module>()
----> 1 from .tools import add_constant, categorical

C:\Users\rebortz\Anaconda\lib\site-packages\statsmodels\tools\tools.py in <module>()
      7 import numpy.linalg as L
      8 from scipy.linalg import svdvals
----> 9 from statsmodels.distributions import (ECDF, monotone_fn_inverter,
     10                                        StepFunction)
     11 from statsmodels.datasets import webuse

C:\Users\rebortz\Anaconda\lib\site-packages\statsmodels\distributions\__init__.py in <module>()
----> 1 from .empirical_distribution import ECDF, monotone_fn_inverter, StepFunction
      2 from .edgeworth import ExpandedNormal
      3 

C:\Users\rebortz\Anaconda\lib\site-packages\statsmodels\distributions\empirical_distribution.py in <module>()
      3 """
      4 import numpy as np
----> 5 from scipy.interpolate import interp1d
      6 
      7 def _conf_set(F, alpha=.05):

C:\Users\rebortz\Anaconda\lib\site-packages\scipy\interpolate\__init__.py in <module>()
    158 from __future__ import division, print_function, absolute_import
    159 
--> 160 from .interpolate import *
    161 from .fitpack import *
    162 

C:\Users\rebortz\Anaconda\lib\site-packages\scipy\interpolate\interpolate.py in <module>()
     14 import numpy as np
     15 import scipy.linalg
---> 16 import scipy.special as spec
     17 from scipy.misc import comb
     18 import math

C:\Users\rebortz\Anaconda\lib\site-packages\scipy\special\__init__.py in <module>()
    587 
    588 from .basic import *
--> 589 from . import specfun
    590 from . import orthogonal
    591 from .orthogonal import *

ImportError: cannot import name specfun

我遇到了与 scipy 0.15.1 中的错误或缺失 scipy.special.specfun 相关的相同问题。将我的 scipy 版本还原为 0.14.0 是一种变通方法并解决了我的问题。使用 conda,您可以恢复使用 conda install scipy=0.14.0 如果需要 0.15.1,从 binstar 上的其他软件包安装也可以。