Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

While importing scipy.stats, gets 'ImportError: DLL load failed: The specified procedure could not be found'

I can't import scipy.stats and get the following error, but somehow

import scipy as sp

still works correctly.

Other library such as numpy, pandas can be imported without any problem.

I have tried reinstalling scipy 1.2.1 in Anaconda, downgrading to scipy 1.2.0, but I still got ImportError specified procedure could not be found.

I use python 3.7.3 and scipy 1.2.1 both installed by Anaconda in the atom text editor.

---------------------------------------------------------------------------
    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ใ
like image 241
Jeff007 Avatar asked Apr 12 '19 22:04

Jeff007


2 Answers

After googling for a while I came across this: https://github.com/conda/conda/issues/6396

Because I was desperate I tried it. And it worked! I solved it by removing the scipy installed by Anaconda and use pip which is pre-installed with python to install scipy instead.

It somehow resolved the problem. Will leave this answer to any unfortunate soul out there.

like image 146
Jeff007 Avatar answered Oct 14 '22 02:10

Jeff007


I've had a similar issue with numpy and scipy from the conda repos. It happens while loading precompiled libs. In my case they are lapack_lite and _umath_linalg. If I uninstall the conda versions and use the pip versions instead it works ok:

$ conda remove --force numpy scipy
$ pip install numpy scipy

Then it works so hopefully this process will work for you but each new package who needs these two will install conda version again due to attached patch version at the end of the repos, unless you want to manually install all dependencies with avoiding these two.

like image 6
MD. SHIFULLAH Avatar answered Oct 14 '22 01:10

MD. SHIFULLAH