Torchvision import

Hello,

Having trouble importing torchvision module in jupyter lab,

Name: torchvision
Version: 0.17.2
Summary: image and video datasets and models for torch deep learning
Home-page: https://github.com/pytorch/vision
Author: PyTorch Core Team
Author-email: soumith@pytorch.org
License: BSD
Location: /Users/.../Python_mode/env/lib/python3.12/site-packages```
So, torchvision can be located in virtual environment, despite this, I get error "ModuleNotFoundError: No module named 'torchvision'" when importing torchvision in jupyter lab,

Does anyone know the reason ?

I get same error message when typing ```!pip3.12 install torchvision``` in jupyter lab,

Many thanks for advise !

What kind of error do you get when trying to install it again?

You could compare this location to the env used in your Jupyter environment to see if another virtual env is used.

Hello @ptrblck_de,

Many thanks for your time on this !

When typing !pip3 install torch torchvision, output is then:

Requirement already satisfied: torchvision in ./env/lib/python3.12/site-packages (0.17.2)
...```

Seems to me it is the same location as the one ```Location: /Users/.../Python_mode/env/lib/python3.12/site-packages```

And as said earlier, imports in Jupyter lab generate same error message.

```import torch
import torchvision```

```ModuleNotFoundError: No module named 'torchvision'```error

What is your thought ?

This is indeed quite strange. Could you create a new virtual environment and install PyTorch with torchvision there just for the sake of debugging?

Hello @ptrblck_de,

Thank you for your time on this !

I finally succeeded by installing torch and torchvision though miniconda and pip but still did not understand why it did not work using pip and virtual environment.
I suspect (as I run on Mac M1) that torch and torchvision versions were not the right ones in regards to M1 architecture…

Thank you !

1 Like