文章目录
- 目测应该是你的系统中有多个版本的python导致指向错误或者conda没有升级,在官网可以查到你想要的版本,在这里就不列举了。
- conda update conda conda install mkl=2018
- python import torch torch.__version__ C:UsersAdministrator>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’ >>> 显示安装成功!
目录
- 安装pytorch运行import torch出错ModuleNotFoundError:No module named'torch'
- 这种情况的出现属于版本不匹配问题
- 直接运行以下代码即可解决问题
- 安装好之后检测一下
- 总结

目测应该是你的系统中有多个版本的python导致指向错误或者conda没有升级,在官网可以查到你想要的版本,在这里就不列举了。
conda update conda
conda install mkl=2018
python
import torch
torch.__version__
C:UsersAdministrator>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'
>>>
显示安装成功!
以上为个人经验,希望能给大家一个参考,也希望大家多多支持风君子博客。
您可能感兴趣的文章:
- pytorch中torch.cat和torch.stack的区别小结
- PyTorch 张量的基本操作
- pytorch中reshape的使用小结
- PyTorch中model.eval()使用与作用小结
- PyTorch中tensor.squeeze() 使用小结