遇到这个问题一般都是环境配置出了问题,安装了新的Python。
所以这时就需要进行环境的配置
File-->Settings-->python interpreter
在其中选择自己已经安装过pytorch的那个环境