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

时间:2015-02-04 15:16:35

标签: python scipy statsmodels

我为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

1 个答案:

答案 0 :(得分:2)

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