'ImportError:DLL加载失败':导入seaborn失败/仅在conpy root作为jupyter笔记本中的内核

时间:2019-03-02 09:28:08

标签: python jupyter-notebook virtualenv seaborn conda

当我使用通常的conda环境在Jupyter笔记本中导入seaborn时,出现错误消息“导入错误:DLL加载失败”。我发现使用conda根环境时没有出现此错误。

   ---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-12-a071ce18c0c5> in <module>
      1 
----> 2 import seaborn as sns
      3 get_ipython().run_line_magic('matplotlib', 'inline')

~\Anaconda3\envs\udemyVenv\lib\site-packages\seaborn\__init__.py in <module>
      4 
      5 # Import seaborn objects
----> 6 from .rcmod import *
      7 from .utils import *
      8 from .palettes import *

~\Anaconda3\envs\udemyVenv\lib\site-packages\seaborn\rcmod.py in <module>
      3 import functools
      4 import matplotlib as mpl
----> 5 from . import palettes, _orig_rc_params
      6 
      7 

~\Anaconda3\envs\udemyVenv\lib\site-packages\seaborn\palettes.py in <module>
     10 from .external.six.moves import range
     11 
---> 12 from .utils import desaturate, set_hls_values, get_color_cycle
     13 from .colors import xkcd_rgb, crayons
     14 

~\Anaconda3\envs\udemyVenv\lib\site-packages\seaborn\utils.py in <module>
      5 
      6 import numpy as np
----> 7 from scipy import stats
      8 import pandas as pd
      9 import matplotlib as mpl

~\Anaconda3\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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\envs\udemyVenv\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 module could not be found.

为什么会这样?有什么方法可以使用我用conda创建的虚拟环境,而不必将内核设置为根环境?

1 个答案:

答案 0 :(得分:0)

几乎肯定是%PATH%环境变量缺少目录。最常见的错误是包含DLL的目录不在%PATH%中,因为它与其余DLL的安装位置不同。