Can't import torch

I’m Running 64 Bit Windows With CUDA 9.2 support , with Conda as my preferred package manager.
Used ’ conda install pytorch -c pytorch’ and managed to install Pytorch 0.4.1 .
When i try to import torch , I get the “module not found error” , I can’t install Torchvision either
IMG_20180809_224122|666x500

Could you try to create a new and clean conda environment and reinstall pytorch and torchvision there?
You will find more information on managing conda environments here.

I created a new Conda environment and installed Pytorch , I still can’t import torch or install Torchvision

15339895805591337528185|374x500

Do you get any error messages?
Could you paste the commands and output as code with three backticks ```?
Your images don’t seem to work.

conda create --name pytorch

activate pytorch

conda install pytorch cuda92 -c pytorch

After Pytorch and all the necessary packages were downloaded and the transaction was succesfully executed,
i did the following:

ipython

import torch

<ipython-input-1-eb42ca6e4af3> in <module>()
----> 1 import torch
ModuleNotFoundError: No module named 'torch'

Did you get any output after the conda install?
Could you try using python instead of ipython?

If you still get import errors, could you try to install the CPU version:

conda install pytorch-cpu -c pytorch 

using python instead of ipython worked
installed torchvision as well!!
Thank You!

2 Likes

Hey, I am having the same issue. Yes, python works, but I prefer iPython terminal. Why can’t iPython find the torch module?

1 Like

Reinstalled fixed the problem. Thanks.

Works for me as well. Thanks!

A little side note for those who are interested why. If conda custom virtualenv doesn’t have ipython package installed, when you fire up ipython from within your custom env it will silently use ipython from conda base environment and base python runtime for this instance of ipython. So, if your base doesn’t have pytorch installed the import error occured.