当我尝试导入scipy.stats时出现错误:
ImportError Traceback (most recent call last)
<ipython-input-320-b66176eb2d0a> in <module>()
----> 1 import scipy.stats
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/stats/__init__.py in <module>()
319 """
320
--> 321 from stats import *
322 from distributions import *
323 from rv import *
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/stats/stats.py in <module>()
191 # Scipy imports.
192 from numpy import array, asarray, dot, ma, zeros, sum
--> 193 import scipy.special as special
194 import scipy.linalg as linalg
195 import numpy as np
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/special/__init__.py in <module>()
525 from _cephes import *
526
--> 527 from basic import *
528 import specfun
529 import orthogonal
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/special/basic.py in <module>()
10 import types
11 import specfun
---> 12 import orthogonal
13
14 __all__ = ['agm', 'ai_zeros', 'assoc_laguerre', 'bei_zeros', 'beip_zeros',
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/special/orthogonal.py in <module>()
85 import numpy as np
86 from numpy import all, any, exp, inf, pi, sqrt
---> 87 from numpy.dual import eig
88
89 # Local imports.
ImportError: No module named dual
numpy中的双模块究竟是什么?在numpy网站上似乎没有任何官方文档。我怎样才能得到这个或如何让scipy.stats运行?
答案 0 :(得分:1)
它基本上是scipy使用的函数的别名索引。
尝试以下代码,让我知道会发生什么。
from numpy.numpy.dual import eig
如果它不起作用,请将下面给出的文件复制到您认为合适的任何文件位置,然后尝试从那里导入。
https://github.com/cheshire/numpy/blob/master/numpy/dual.py
或者你可以简单地,不导入那个特定的模块,因为scipy在没有它的情况下可以正常工作。