You ask — we answer!

No module named 'torch'

Error:

ModuleNotFoundError                       Traceback (most recent call last)
 in 
     14 import matplotlib.pyplot as plt
     15 
---> 16 import torch
     17 import torch.nn as nn
     18 import torch.optim as optim
ModuleNotFoundError: No module named 'torch'

How to fix

pip3 install torch torchvision

See also: https://pytorch.org/get-started/locally/



Updated: 18.03.2025

Published: 10.01.2020


Still have questions? Write to us!

By clicking «I Accept» you confirm that you have read and accepted the website Terms and Conditions, Privacy Policy, and Moneyback Policy.