No module named 'torch.nn'; 'torch' is not a package 月蜗 2022-05-25 1,382 阅读1分钟 如果你恰好建立了一个torch.py文件,那么此文章有用。 问题描述: 当我们: import torch没有发现问题,import torch.nn时出现此问题。 解决办法: 将torch.py文件换一个名字。 因为此时torch文件与使用的系统的torch文件重名,会触发该问题。