Skip to content Skip to sidebar Skip to footer

How Can I Fix This Pytorch Error On Windows? (modulenotfounderror: No Module Named 'torch')

Edit: You might want to skip to the end of the question first, I've followed some advice in comments / answers and the current error is different from the original (appears to be r

Solution 1:

Pytorch requires 3.5 <= python < 3.8. Setup an environment with:

conda create -n pytorch python=3.7
conda activate pytorch
conda install pytorch

You should also make sure that you launch the installed python interpreter from this environment (YourAnacondaInstallDirectory\envs\pytorch\python.exe) from the activated conda environment! The later is important because conda will export certain environment variables (have a look at this for a related issue caused by missing envionment variables).

Solution 2:

Use This Let me Know if it will Work!

pip install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp37-cp37m-win_amd64.whl

Solution 3:

As you know, Pytorch requires 3.5 <= python < 3.8. Use Python 3.7 or slightly earlier.

If you would like to install it with plain pip rather than conda:

Do NOT try to install with simple pip install torch. Instead, as you say, go to https://pytorch.org/, in the colorful grid, click on pip, copy the command, open a command prompt as an administrator (right-click and select "Run as Administrator") then paste the command, which should look something like:

pip install torch===1.5.1 torchvision===0.6.1 -f https://download.pytorch.org/whl/torch_stable.html

Then, edit the command to replace pip with the full path to your version of pip, e.g.:

"C:\Program Files\Python37\Scripts\pip.exe" pip install torch===1.5.1 torchvision===0.6.1 -f https://download.pytorch.org/whl/torch_stable.html

(You don't need to edit the command as long as Python 3.7 is in your path.)

Post a Comment for "How Can I Fix This Pytorch Error On Windows? (modulenotfounderror: No Module Named 'torch')"