Pytorch has an error Attribute Error: module 'torch' has no attribute '_six'

1. Problem description : I am using jupyter extension in VScode to connect to the server remotely.

2. torch version : 2.0

3. pytorch version : 1.9.1

4. The cause of the problem : there is no '_six.py' file in torch version 2.0 or later

5. How to view py files in torch?
I am using anaconda, the location of the py file in torch is:

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

insert image description here
6. Solution
(1) I first tried to copy the '_six.py' file in torch1.9 to torch2.0, but it still didn't work (I don't know why, can someone explain it?)
Then I reinstalled torch1.9.1, the problem is solved!
Proceed as follows:

pip uninstall torch
pip install torch==1.9.1

Tips: Ifyou find a '_six.py' file in step 5 , you can click to restart the jupyter kernel to solve it.
insert image description here

Guess you like

Origin blog.csdn.net/qq_44727287/article/details/129903108