Skip to content
Home » ImportError: cannot import name ‘PY3’ from ‘torch._six’

ImportError: cannot import name ‘PY3’ from ‘torch._six’

To solve ImportError: cannot import name ‘PY3’ from ‘torch._six’ error follow below methods.

ERROR LOG

File "/home/fypadmin/anaconda3/envs/pytorch1/lib/python3.8/site-packages/torchvision/datasets/utils.py", line 11, in from torch._six import PY3 
ImportError: cannot import name 'PY3' from 'torch._six' (/home/fypadmin/anaconda3/envs/pytorch1/lib/python3.8/site-packages/torch/_six.py)

How to solve ImportError: cannot import name ‘PY3’ from ‘torch._six’ ?

The problem is that your ‘torchvision’ and ‘pytorch’ versions did not match. As a result, you must update your ‘torchvision’ and ‘pytorch’ versions to the latest versions.

pip install --upgrade torch torchvision

Alternative to Solve ImportError: cannot import name ‘PY3’ from ‘torch._six’

Fix the issue by Installing PY3 in your environment

pip install py3

Hope the above solution works.

Also read :

WARNING: Value for scheme.data does not match. Please report this
‘NoneType’ object has no attribute ‘value’ PgAdmin4