ImportError: DLL load failed while importing _multiarray_umath“找不到指定模块”报错解决

项目场景:

UserWarning: mkl-service package failed to import, therefore Intel® 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 "F:\miniconda\envs\demo\lib\site-packages\numpy\core_init
.py", line 23, in
from . import multiarray
File “F:\miniconda\envs\demo\lib\site-packages\numpy\core\multiarray.py”, line 10, in
from . import overrides
File “F:\miniconda\envs\demo\lib\site-packages\numpy\core\overrides.py”, line 6, in
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\Administrator\Desktop\demo_project\main.py”, line 6, in
import torch.cuda
File “F:\miniconda\envs\demo\lib\site-packages\torch_init_.py”, line 613, in
C.initExtension(manager_path())
File "F:\miniconda\envs\demo\lib\site-packages\torch\cuda_init
.py", line 685, in
from . import amp
File "F:\miniconda\envs\demo\lib\site-packages\torch\cuda\amp_init
.py", line 1, in
from .autocast_mode import autocast, custom_fwd, custom_bwd # noqa: F401
File “F:\miniconda\envs\demo\lib\site-packages\torch\cuda\amp\autocast_mode.py”, line 5, in
import numpy as np
File “F:\miniconda\envs\demo\lib\site-packages\numpy_init_.py”, line 141, in
from . import core
File “F:\miniconda\envs\demo\lib\site-packages\numpy\core_init_.py”, line 49, in
raise ImportError(msg)
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 “F:\miniconda\envs\demo\python.exe”
  • The NumPy version is: “1.24.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: 找不到指定的模块。
在这里插入图片描述


问题描述

import torch.cuda
import random


# See PyCharm help at https://www.jetbrains.com/help/pycharm/
def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')
    # print(cv2.version)
    print(torch.cuda.is_available())

# 测试随机抽样
List = ['R', 'G', 'B']
Samples = random.choices(List, weights=[2, 5, 3], k=100)
print(Samples)

解决方案:

打开编辑配置,修改环境变量添加如下代码

在这里插入图片描述
在这里插入图片描述

Path=F:\miniconda\envs\demo\Library\bin

结果:
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值