【问题标题】:Running numpy using anaconda and VS Code使用 anaconda 和 VS Code 运行 numpy
【发布时间】:2020-09-08 03:05:51
【问题描述】:

我正在尝试让 VScode 与 anaconda 一起工作,但遇到 numpy 问题。我已经设法让 VScode 从 VScode 使用正确的 python 环境(ctrl+shift+P,输入 Python:Select Interpreter 并选择适当的选项)。

但是,当我在脚本中键入“import numpy”时,我收到以下错误消息:

C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
  from . import _distributor_init
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
    from . import multiarray
  File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
    from . import overrides
  File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\[NAME]\Documents\python\sandpit\hello.py", line 2, in <module>
    import numpy
  File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core
  File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\core\__init__.py", line 54, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
  1. Check that you expected to use Python3.8 from "C:\ProgramData\Anaconda3\envs\sandpit\python.exe",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.18.1" you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.

Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.

Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.

我已经成功地从 anaconda 命令提示符调用了“import numpy”命令,所以问题似乎出在 VS-Code 上?

我也尝试使用以下命令conda install numpy --force-reinstall从环境中重新安装numpy,但这没有效果?

【问题讨论】:

    标签: python numpy visual-studio-code anaconda


    【解决方案1】:

    尝试从您激活的 conda 环境中启动 VS Code。如果您在 shell 有机会激活 conda 环境之前设法运行代码,通常会出现此类错误。

    【讨论】:

      【解决方案2】:

      还有一步

      1. 启动Anaconda 3 powershell
      2. conda init cmd.exe #允许cmd运行VScode
      3. 点击命令code启动VScode。

      【讨论】:

        猜你喜欢
        • 2021-11-18
        • 1970-01-01
        • 1970-01-01
        • 2021-08-04
        • 2018-11-03
        • 1970-01-01
        • 2017-10-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多