ImportError: cannot import name 'PY3' from 'torch._six'
KeepLost opened this issue · comments
When I run
python -c "import torch_mimicry as mmc"
with torch-mimicry==0.1.16
and pytorch==1.12.1
, I met the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/root/miniconda3/envs/losthub/lib/python3.9/site-packages/torch_mimicry/__init__.py", line 1, in <module>
from torch_mimicry import nets, training, metrics, datasets, modules
File "/root/miniconda3/envs/losthub/lib/python3.9/site-packages/torch_mimicry/metrics/__init__.py", line 2, in <module>
from .compute_fid import *
File "/root/miniconda3/envs/losthub/lib/python3.9/site-packages/torch_mimicry/metrics/compute_fid.py", line 12, in <module>
from torch_mimicry.datasets.image_loader import get_dataset_images
File "/root/miniconda3/envs/losthub/lib/python3.9/site-packages/torch_mimicry/datasets/__init__.py", line 1, in <module>
from . import imagenet
File "/root/miniconda3/envs/losthub/lib/python3.9/site-packages/torch_mimicry/datasets/imagenet/__init__.py", line 1, in <module>
from .imagenet import *
File "/root/miniconda3/envs/losthub/lib/python3.9/site-packages/torch_mimicry/datasets/imagenet/imagenet.py", line 14, in <module>
from .imagenet_utils import check_integrity, download_and_extract_archive, extract_archive, \
File "/root/miniconda3/envs/losthub/lib/python3.9/site-packages/torch_mimicry/datasets/imagenet/imagenet_utils.py", line 13, in <module>
from torch._six import PY3
ImportError: cannot import name 'PY3' from 'torch._six' (/root/miniconda3/envs/losthub/lib/python3.9/site-packages/torch/_six.py)
After I checked the _six.py
script, I found that this script doesn't import any module named PY3
. And in imagenet_utils.py
, PY3
is used to do some sort of condition checking e.g.
elif _is_tarxz(from_path) and PY3:
# .tar.xz archive only supported in Python 3.x
with tarfile.open(from_path, 'r:xz') as tar:
tar.extractall(path=to_path)
I hope that the developer can fix this issue.
@KeepLost I think this is because your torchvision version is not compatible with torch (see stackoverflow issue). To prevent this issue, I have recently updated the repository where I froze the versions that worked for my machine. Please install the latest master branch with pip install git+https://github.com/kwotsin/mimicry.git
and see if this issue persists, thank you