Torchvision import

de_Beyssac_Olivier: <p>Hello,</p>
<p>Having trouble importing torchvision module in jupyter lab,</p>
<pre><code class="lang-auto">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 !</code></pre>

ptrblck: <aside class="quote no-group" data-username="de_Beyssac_Olivier" data-post="1" data-topic="201446">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/de_beyssac_olivier/48/68740_2.png" class="avatar"> de_Beyssac_Olivier:</div>
<blockquote>
<pre><code class="lang-auto">
I get same error message when typing ```!pip3.12 install torchvision``` in jupyter lab,
</code></pre>
</blockquote>
</aside>
<p>What kind of error do you get when trying to install it again?</p>
<aside class="quote no-group" data-username="de_Beyssac_Olivier" data-post="1" data-topic="201446">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/de_beyssac_olivier/48/68740_2.png" class="avatar"> de_Beyssac_Olivier:</div>
<blockquote>
<p><code>Location: /Users/.../Python_mode/env/lib/python3.12/site-packages</code></p>
</blockquote>
</aside>
<p>You could compare this location to the env used in your Jupyter environment to see if another virtual env is used.</p>

de_Beyssac_Olivier: <p>Hello <span class="mention">@ptrblck_de</span>,</p>
<p>Many thanks for your time on this !</p>
<p>When typing <code>!pip3 install torch torchvision</code>, output is then:</p>
<pre data-code-wrap="Requirement"><code class="lang-Requirement">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 ?</code></pre>

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

de_Beyssac_Olivier: <p>Hello <span class="mention">@ptrblck_de</span>,</p>
<p>Thank you for your time on this !</p>
<p>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.<br>
I suspect (as I run on Mac M1) that torch and torchvision versions were not the right ones in regards to M1 architecture…</p>
<p>Thank you !</p>