【发布时间】:2020-07-06 01:43:02
【问题描述】:
我对python有点陌生,我正在尝试学习一些机器学习,
目前我正在尝试在 python 3.7 中使用两个模块,Torch 和 Numpy,并且我正在尝试使用 Visual Studio 2019。
我已经使用以下命令设置了 anaconda3 环境
conda create -n myenv python pytorch numpy numpydoc
conda activate myenv
在 VS 中,我选择了这个作为要使用的环境。见screenshot。
但我无法运行我的程序,我收到此错误
Message=
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.7 from "C:\Users\Djod\anaconda3\envs\myenv\python.exe"
* The NumPy version is: "1.18.5"
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: The specified module could not be found.
Source=C:\Users\Djod\source\repos\Pytorch-test\Pytorch-test\run.py
StackTrace:
File "C:\Users\Djod\source\repos\Pytorch-test\Pytorch-test\run.py", line 2, in <module>
import numpy as np
本指南有一些关于 Eclipse 和 VS 代码的说明,但没有针对 Visual Studio,所以我有点不知道该怎么做。
我可以从 anaconda 提示符运行我的 python 文件,但不能从 Visual Studio 中运行。 我也用 Python 3.8 进行了测试,结果是一样的。
任何帮助将不胜感激。
【问题讨论】:
-
您是否尝试过使用 official instructions 安装 PyTorch?
-
这个问题不是 PyTorch 独有的,使用 conda 的说明会产生相同的结果。
标签: python numpy conda visual-studio-2019