[英]ModuleNotFoundError: No module named 'torch'
I try to use pytorch module by conda but I get an error我尝试通过 conda 使用 pytorch 模块,但出现错误
Traceback (most recent call last):
File "train.py", line 8, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
when I write conda list | findstr torch
当我写
conda list | findstr torch
conda list | findstr torch
I see that torch is installed: conda list | findstr torch
我看到火炬已安装:
I tried:我试过:
conda update conda -n root
conda install mkl=2018
but get:但得到:
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
Could Not Find C:\WINDOWS\TEMP\conda-23721-26470.tmp
Could Not Find C:\WINDOWS\TEMP\tmpry_dlvar.bat
and the same error occurrence和同样的错误发生
Try the below mentioned one, surely it will work.尝试下面提到的一个,肯定会起作用。
conda install -c pytorch pytorch康达安装-c pytorch pytorch
This worked for me这对我有用
conda install pytorch torchvision -c pytorch
Try to run the following on the local environment as given in the pytorch website during installation.安装时尝试在pytorch官网给出的本地环境中运行以下命令。 Open Jupyter Notebook locally and run the following
在本地打开 Jupyter Notebook 并运行以下命令
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
if this works then most likely the environment variable is not set properly.如果这有效,那么很可能是环境变量设置不正确。 I hope this helps.
我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.