I successfully installed pytorch via conda:
JavaScript
x
2
1
conda install pytorch-cpu torchvision-cpu -c pytorch
2
I also successfully installed pytorch via pip:
JavaScript
1
3
1
pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp36-cp36m-win_amd64.whl
2
pip3 install torchvision
3
But, it only works in a jupyter notebook. Whenever I try to execute a script from the console, I get the error message:
No module named “torch”
Advertisement
Answer
Try to install PyTorch using pip:
First create a Conda environment using:
JavaScript
1
2
1
conda create -n env_pytorch python=3.6
2
Activate the environment using:
JavaScript
1
2
1
conda activate env_pytorch
2
Now install PyTorch using pip:
JavaScript
1
2
1
pip install torchvision
2
Note: This will install both torch and torchvision.
Now go to Python shell and import using the command:
JavaScript
1
3
1
import torch
2
import torchvision
3