【问题标题】:Trouble importing modules into ipython将模块导入 ipython 时遇到问题
【发布时间】:2019-08-24 14:44:42
【问题描述】:

在新安装的 Windows 10 机器上,我安装了最新的 64 位版本的 anaconda。现在,当我尝试将模块导入 ipython 时,出现错误。下面复制了一些示例错误。

我是 Python 和编程的新手,希望能得到一些帮助。这是一台全新的联想笔记本电脑,因此不会出现任何 Python 版本冲突等问题(因为之前没有安装任何东西)。

In [1]: import sklearn
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-b7c74cbf5af0> in <module>
----> 1 import sklearn

C:\Software\anaconda3\lib\site-packages\sklearn\__init__.py in <module>
     74 else:
     75     from . import __check_build
---> 76     from .base import clone
     77     from .utils._show_versions import show_versions
     78

C:\Software\anaconda3\lib\site-packages\sklearn\base.py in <module>
     11 import re
     12
---> 13 import numpy as np
     14
     15 from . import __version__

C:\Software\anaconda3\lib\site-packages\numpy\__init__.py in <module>
    138
    139     # Allow distributors to run custom init code
--> 140     from . import _distributor_init
    141
    142     from . import core

C:\Software\anaconda3\lib\site-packages\numpy\_distributor_init.py in <module>
     32
     33 with RTLD_for_MKL():
---> 34     from . import _mklinit
     35
     36 del RTLD_for_MKL

ImportError: DLL load failed: The specified module could not be found.

In [2]: import matplotlib.pyplot as plt
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt

C:\Software\anaconda3\lib\site-packages\matplotlib\__init__.py in <module>
    136 # cbook must import matplotlib only within function
    137 # definitions, so it is safe to import from it here.
--> 138 from . import cbook, rcsetup
    139 from matplotlib.cbook import (
    140     MatplotlibDeprecationWarning, dedent, get_label, sanitize_sequence)

C:\Software\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py in <module>
     29 from weakref import WeakMethod
     30
---> 31 import numpy as np
     32
     33 import matplotlib

C:\Software\anaconda3\lib\site-packages\numpy\__init__.py in <module>
    138
    139     # Allow distributors to run custom init code
--> 140     from . import _distributor_init
    141
    142     from . import core

C:\Software\anaconda3\lib\site-packages\numpy\_distributor_init.py in <module>
     32
     33 with RTLD_for_MKL():
---> 34     from . import _mklinit
     35
     36 del RTLD_for_MKL

ImportError: DLL load failed: The specified module could not be found.

In [3]: import pystan
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-ca8618bb8e4a> in <module>
----> 1 import pystan

ModuleNotFoundError: No module named 'pystan'

In [4]:

【问题讨论】:

    标签: python-3.x windows anaconda ipython conda


    【解决方案1】:

    经过大量谷歌搜索,我发现一些网站涉及一些密切相关的问题(例如https://github.com/stan-dev/pystan/issues/520)。碰巧需要在 Windows 路径中添加一些 anaconda 目录。我在路径中添加了anaconda/Library/bin、anaconda/Scripts。现在一切都按预期工作。

    【讨论】:

      猜你喜欢
      • 2012-01-07
      • 2020-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-21
      • 1970-01-01
      • 2011-01-17
      相关资源
      最近更新 更多