原本在conda虚拟环境里已经安装好了torch,在用pip list查询安装包的时候,也是有torch的。
出现问题是在pycharm里
然后去conda里试了一下,import torch,发现确实没装好
第一步解决方法:卸载后重新安装
发现还是找不到
第二步解决方法:
改用conda直接安装
在激活的虚拟环境里,引入清华镜像资源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
然后安装对应版本,这里我安装的是0.4.0
conda install pytorch==0.4.0
成功了
anoconda prompt查看torch版本的方法
>>> import torch
>>> torch.__version__