安装pytorch运行import torch出错modulenotfounderror:no module named'torch'

这种情况的出现属于版本不匹配问题
目测应该是你的系统中有多个版本的python导致指向错误或者conda没有升级,在官网可以查到你想要的版本,在这里就不列举了。
直接运行以下代码即可解决问题
conda update conda conda install mkl=2018
安装好之后检测一下
python import torch torch.__version__
c:\users\administrator>python python 3.8.5 (default, sep 3 2020, 21:29:08) [msc v.1916 64 bit (amd64)] :: anaconda, inc. on win32 warning: this python interpreter is in a conda environment, but the environment has not been activated. libraries may fail to load. to activate this environment please see https://conda.io/activation type "help", "copyright", "credits" or "license" for more information. >>> import torch >>> torch.__version__ '1.7.1' >>>
显示安装成功!
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论