欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

pytorch的ModuleNotFoundError: No module named 'torch'

程序员文章站 2022-05-28 22:27:11
...

我的问题是python安装版本和torch的版本不对应问题

pytorch                   0.3.1           py36_cuda9.0.176_cudnn7.0.5_2  [cuda90]  pytorch
python                    3.7.3                h0371630_0 

在conda中对python的版本进行指定的修改,将3.7版本将为3.6版本

conda update python=3.6
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> exit()

总之,torch还是tensorflow都是和python有版本的对应关系的,新手都应该注意。