我无法导入scipy.stats并收到以下错误,但不知何故
import scipy as sp
仍然可以正常工作。
可以导入其他库,例如numpy,pandas。
我尝试在Anaconda中重新安装scipy 1.2.1,降级为scipy 1.2.0,但仍然找不到ImportError指定的过程。
我使用都由Anaconda在原子文本编辑器中安装的python 3.7.3和scipy 1.2.1。
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-dcc8e03bb4b3> in <module>
----> 1 from scipy import stats
~\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>
22
23 # for root finding for discrete distribution ppf, and max likelihood estimation
---> 24 from scipy import optimize
25
26 # for functions of continuous distributions (e.g. moments, entropy, cdf)
~\Anaconda3\lib\site-packages\scipy\optimize\__init__.py in <module>
385
386 from .optimize import *
--> 387 from ._minimize import *
388 from ._root import *
389 from ._root_scalar import *
~\Anaconda3\lib\site-packages\scipy\optimize\_minimize.py in <module>
28 from ._trustregion_krylov import _minimize_trust_krylov
29 from ._trustregion_exact import _minimize_trustregion_exact
---> 30 from ._trustregion_constr import _minimize_trustregion_constr
31
32 # constrained minimization
~\Anaconda3\lib\site-packages\scipy\optimize\_trustregion_constr\__init__.py in <module>
2
3
----> 4 from .minimize_trustregion_constr import _minimize_trustregion_constr
5
6 __all__ = ['_minimize_trustregion_constr']
~\Anaconda3\lib\site-packages\scipy\optimize\_trustregion_constr\minimize_trustregion_constr.py in <module>
2 import time
3 import numpy as np
----> 4 from scipy.sparse.linalg import LinearOperator
5 from .._differentiable_functions import VectorFunction
6 from .._constraints import (
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py in <module>
115 from .dsolve import *
116 from .interface import *
--> 117 from .eigen import *
118 from .matfuncs import *
119 from ._onenormest import *
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py in <module>
9 from __future__ import division, print_function, absolute_import
10
---> 11 from .arpack import *
12 from .lobpcg import *
13
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py in <module>
20 from __future__ import division, print_function, absolute_import
21
---> 22 from .arpack import *
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py in <module>
43 __all__ = ['eigs', 'eigsh', 'svds', 'ArpackError', 'ArpackNoConvergence']
44
---> 45 from . import _arpack
46 import numpy as np
47 import warnings
ImportError: DLL load failed: The specified procedure could not be foundใ
答案 0 :(得分:0)
谷歌搜索一段时间后,我发现: https://github.com/conda/conda/issues/6396
因为我很拼命所以尝试了。而且有效! 我通过删除Anaconda安装的scipy解决了 使用预先安装了python的pip来安装scipy。
它以某种方式解决了问题。 将会把这个答案留给任何不幸的灵魂。
答案 1 :(得分:0)
我在conda仓库中遇到了类似numpy和scipy的问题。它在加载预编译的库时发生。就我而言,它们是lapack_lite和_umath_linalg。如果我卸载conda版本并使用pip版本,则可以正常运行。
解决方案:
$ conda remove --force numpy, scipy
$ pip install numpy, scipy
然后它可以正常运行,因此希望此过程对您有用。但是每个需要这两个软件包的新软件包都将由于安装在回购协议末尾的补丁版本而再次安装conda版本,除非您想手动安装所有依赖项以避免这两个软件包。
答案 2 :(得分:0)
我遇到了同样的问题,只是运行 pip instll scipy -U
来更新 Scipy