No module named ‘torchvision’ despite being installed

Hi there
I installed torch vision by ‘conda install -c pytorch torchvision’
but I am getting an import error when importing it into my code.

The code is

import torchvision

I check sys.path but there no problem.
But I can import torchvision on my terminal after warning that “UserWarning: Failed to load image Python extension”
Then the version is 0.13.1a0

Please help me

This could mean that the Python environment used in your terminal is different from the one used before.

What kind of import error are you seeing?

I getted the no module named ‘torchvision’ error.

Before getting this error, torch and matplotlib were not imported at the same time, even though each was imported. So I reinstalled torch, but torchvision is not imported.

I also reinstalled torchvision, and at first it imported fine in the terminal. But after reinstalling, the Userwarning pops up😂

You can ignore the UserWarning as it would only indicate the torchvision.io backend wasn’t built in the pip wheel / conda binary, which might be expected.

Thank you.

So what do I need to do to import torchvision not in terminal but inside code?

Hi

I solved the problem after reinstalling condo again. Thank you :slight_smile: