ImportError: cannot import name 'PY3' from 'torch._six'
I am testing ZED Camera with the code on https://github.com/stereolabs/zed-pytorch. While running the final command: python zed_object_detection.py --config-file configs/caffe2/e2e_mask_rcnn_R_50_C4_1x_caffe2.yaml --min-image-size 256
I get the following error:
Traceback (most recent call last):
File &quot;zed_object_detection.py&quot;, line 6, in 
from predictor import COCODemo
File &quot;/home/fypadmin/Desktop/23Apr_ZED/zed-pytorch/predictor.py&quot;, line 4, in 
from torchvision import transforms as T
File &quot;/home/fypadmin/anaconda3/envs/pytorch1/lib/python3.8/site-packages/torchvision/init.py&quot;, line 4, in 
from torchvision import datasets
File &quot;/home/fypadmin/anaconda3/envs/pytorch1/lib/python3.8/site-packages/torchvision/datasets/init.py&quot;, line 1, in 
from .lsun import LSUN, LSUNClass
File &quot;/home/fypadmin/anaconda3/envs/pytorch1/lib/python3.8/site-packages/torchvision/datasets/lsun.py&quot;, line 19, in 
from .utils import verify_str_arg, iterable_to_str
File &quot;/home/fypadmin/anaconda3/envs/pytorch1/lib/python3.8/site-packages/torchvision/datasets/utils.py&quot;, 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)
I am new to ML and I am running pytorch 1.8.1. Looking forward to any help. Thanks

For this question, the reason is that your 'torchvision' and 'pytorch' version, they didn't match. So, you need to upgrade your 'torchvision' and 'pytorch' version to the new version
pip install --upgrade torch torchvision

