Import pytorch and torchvision

i have macbook pro. I have installed anaconda 3.6 and pytorch library. but i m getting following errors in jupyter notebook:
ImportError: No module named torchvision

Maybe a stupid question, but did you install torchvision? :slight_smile:

1 Like

PANKAJs-MacBook-Pro:~ pankajjadhav$ source activate python27
(python27) PANKAJs-MacBook-Pro:~ pankajjadhav$ pip install torchvision
Requirement already satisfied: torchvision in ./anaconda3/envs/python27/lib/python2.7/site-packages/torchvision-0.1.9-py2.7.egg
Requirement already satisfied: numpy in ./anaconda3/envs/python27/lib/python2.7/site-packages (from torchvision)
Requirement already satisfied: pillow in ./anaconda3/envs/python27/lib/python2.7/site-packages (from torchvision)
Requirement already satisfied: six in ./anaconda3/envs/python27/lib/python2.7/site-packages (from torchvision)
Requirement already satisfied: torch in ./anaconda3/envs/python27/lib/python2.7/site-packages (from torchvision)
Requirement already satisfied: pyyaml in ./anaconda3/envs/python27/lib/python2.7/site-packages (from torch->torchvision)

notebook:
import torchvision

ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import torchvision

ModuleNotFoundError: No module named ‘torchvision’

In [3]:

import torch

ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import torch

ModuleNotFoundError: No module named ‘torch’

Ok, I see. How did you start the Jupyter notebook server?
Could you please just activate your conda environment, type python and try to import torch and torchvision there?

ya its working there
(python27) PANKAJs-MacBook-Pro:~ pankajjadhav$ python
Python 2.7.14 |Anaconda custom (64-bit)| (default, Oct 5 2017, 02:28:52)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import torch
import torchvision

getting same error when using python notebook.

(python27) PANKAJs-MacBook-Pro:~ pankajjadhav$ jupyter notebook

import torchvision

ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import torchvision

ModuleNotFoundError: No module named ‘torchvision’

In [2]:

import torchvision

ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import torchvision

ModuleNotFoundError: No module named ‘torchvision’

1 Like

Could you try to reinstall the packages using conda?