背景
在pycharm中导入包import torch时报如下错误:
ModuleNotFoundError: No module named ‘torch’
解决方法
(1)下载torch-1.3.0+cu100-cp36-cp36m-linux_x86_64.whl:
study:~$ wget https://download.pytorch.org/whl/cu100/torch-1.3.0%2Bcu100-cp36-cp36m-linux_x86_64.whl
(2)下载torchvision-0.4.1+cu100-cp36-cp36m-linux_x86_64.whl:
study:~$ wget https://download.pytorch.org/whl/cu100/torchvision-0.4.1%2Bcu100-cp36-cp36m-linux_x86_64.whl
(3)在相应的环境下安装(我这里时安装在虚拟环境nlpStage中):
(nlpStage) study:~$ ls
torch-1.3.0+cu100-cp36-cp36m-linux_x86_64.whl
torchvision-0.4.1+cu100-cp36-cp36m-linux_x86_64.whl
(nlpStage) study:~$ pip install torch-1.3.0+cu100-cp36-cp36m-linux_x86_64.whl
...
Successfully installed torch-1.3.0+cu100
(nlpStage) study:~$ pip install torchvision-0.4.1+cu100-cp36-cp36m-linux_x86_64.whl
...
Successfully installed torchvision-0.4.1+cu100