jupyter notebook调用numpy报错:Importing the numpy C-extensions failed.

报错信息

ImportError:

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

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

* The Python version is: Python3.8 from "D:\miniconda3\envs\cv38\python.exe"
* The NumPy version is: "1.20.3"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: 找不到指定的模块。
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
D:\miniconda3\envs\cv38\lib\site-packages\numpy\core\__init__.py in 
     21 try:
---> 22     from . import multiarray
     23 except ImportError as exc:

D:\miniconda3\envs\cv38\lib\site-packages\numpy\core\multiarray.py in 
     11 
---> 12 from . import overrides
     13 from . import _multiarray_umath

D:\miniconda3\envs\cv38\lib\site-packages\numpy\core\overrides.py in 
      6 
----> 7 from numpy.core._multiarray_umath import (
      8     add_docstring, implement_array_function, _get_implementing_args)

ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的模块。

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
 in 
----> 1 import torch
      2 
      3 print(torch.__version__)

D:\miniconda3\envs\cv38\lib\site-packages\torch\__init__.py in 
    603 
    604 # Shared memory manager needs to know the exact location of manager executable
--> 605 _C._initExtension(manager_path())
    606 del manager_path
    607 

D:\miniconda3\envs\cv38\lib\site-packages\torch\cuda\__init__.py in 
    605 from . import profiler
    606 from . import nvtx
--> 607 from . import amp

D:\miniconda3\envs\cv38\lib\site-packages\torch\cuda\amp\__init__.py in 
----> 1 from .autocast_mode import autocast, custom_fwd, custom_bwd  # noqa: F401
      2 from .grad_scaler import GradScaler  # noqa: F401

D:\miniconda3\envs\cv38\lib\site-packages\torch\cuda\amp\autocast_mode.py in 
      4 import collections
      5 try:
----> 6     import numpy as np
      7     HAS_NUMPY = True
      8 except ModuleNotFoundError:

D:\miniconda3\envs\cv38\lib\site-packages\numpy\__init__.py in 
    143     from . import _distributor_init
    144 
--> 145     from . import core
    146     from .core import *
    147     from . import compat

D:\miniconda3\envs\cv38\lib\site-packages\numpy\core\__init__.py in 
     46 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
     47         __version__, exc)
---> 48     raise ImportError(msg)
     49 finally:
     50     for envkey in env_added:

ImportError: 

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

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.8 from "D:\miniconda3\envs\cv38\python.exe"
  * The NumPy version is: "1.20.3"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: 找不到指定的模块。

原因

conda 安装的numpy 有一点问题,卸载后使用pip 重装即可。

解决方法

$ conda remove numpy

$ pip install numpy

此时再用conda list | grep numpy 命令查看numpy版本,发现已经变成pip安装版的了。

重启jupyter notebook,可以运行程序。

你可能感兴趣的:(python,anaconda,pip)