Pytorch出现错误Attribute Error: module ‘torch‘ has no attribute ‘_six‘

1. 问题描述:我是在VScode中使用jupyter拓展,远程连接服务器。

2. torch版本:2.0

3. pytorch版本: 1.9.1

4. 问题原因:torch 2.0版本以后中没有 ‘_six.py’ 文件

5. 如何查看torch中的py文件?
我是用的anaconda,torch中的py文件位置为:

/envs/环境名/lib/python版本号(比如:python3.8)/site-packages/torch


6. 解决办法
(1)我第一开始试着把torch1.9中的’_six.py’文件复制到torch2.0中,发现还是不行(不知道为啥,有大佬能解释一下吗?)
然后我又重新装了torch1.9.1,问题解决了!
步骤如下:

pip uninstall torch
pip install torch==1.9.1

Tips: 如果在步骤5中发现有’_six.py’文件,可以点击重启jupyter kernel即可解决。

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年7月12日
下一篇 2023年7月12日

相关推荐