Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'PY3' from 'torch._six' on fresh install of bolts #581

Closed
davzaman opened this issue Mar 7, 2021 · 8 comments · Fixed by #580
Closed

cannot import name 'PY3' from 'torch._six' on fresh install of bolts #581

davzaman opened this issue Mar 7, 2021 · 8 comments · Fixed by #580
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@davzaman
Copy link

davzaman commented Mar 7, 2021

🐛 Bug

Fresh install of pytorch-lightning and pytorch-lightning bolts leads to error cannot import name 'PY3' from 'torch._six'

Looks like it was renamed to PY37 in torch._six. I changed all references to PY3 to PY37 inside pl_bolts/datasets/imagenet_dataset.py and the problem resolved.

Traceback (most recent call last):
  File "debugtuner.py", line 4, in <module>
    from pl_bolts.datamodules import MNISTDataModule
  File "/home/davina/miniconda3/envs/ap/lib/python3.8/site-packages/pl_bolts/__init__.py", line 47, in <module>
    from pl_bolts import callbacks, datamodules, datasets, losses, metrics, models, optimizers, transforms, utils
  File "/home/davina/miniconda3/envs/ap/lib/python3.8/site-packages/pl_bolts/datamodules/__init__.py", line 2, in <module>
    from pl_bolts.datamodules.binary_mnist_datamodule import BinaryMNISTDataModule
  File "/home/davina/miniconda3/envs/ap/lib/python3.8/site-packages/pl_bolts/datamodules/binary_mnist_datamodule.py", line 4, in <module>
    from pl_bolts.datasets import BinaryMNIST
  File "/home/davina/miniconda3/envs/ap/lib/python3.8/site-packages/pl_bolts/datasets/__init__.py", line 11, in <module>
    from pl_bolts.datasets.imagenet_dataset import extract_archive, parse_devkit_archive, UnlabeledImagenet
  File "/home/davina/miniconda3/envs/ap/lib/python3.8/site-packages/pl_bolts/datasets/imagenet_dataset.py", line 12, in <module>
    from torch._six import PY3
ImportError: cannot import name 'PY3' from 'torch._six' (/home/davina/miniconda3/envs/ap/lib/python3.8/site-packages/torch/_six.py)

Code sample

from pl_bolts.datamodules import MNISTDataModule

Expected behavior

the package should run with no error.

Environment

  • PyTorch Version (e.g., 1.0): 1.8
  • OS (e.g., Linux): MacOs
  • How you installed PyTorch (conda, pip, source): conda
  • Build command you used (if compiling from source): pip install
  • Python version: 3.8
  • CUDA/cuDNN version: 10.1
  • GPU models and configuration: 4 nvidia gpus
  • Any other relevant information:
@davzaman davzaman added fix fixing issues... help wanted Extra attention is needed labels Mar 7, 2021
@github-actions
Copy link

github-actions bot commented Mar 7, 2021

Hi! thanks for your contribution!, great first issue!

@kaushikb11 kaushikb11 self-assigned this Mar 8, 2021
@kaushikb11 kaushikb11 linked a pull request Mar 8, 2021 that will close this issue
8 tasks
@Borda
Copy link
Member

Borda commented Mar 8, 2021

@davzaman mind share what you mean fresh install, from git/master, or from pip?

@davzaman
Copy link
Author

davzaman commented Mar 8, 2021

Sure, I installed from conda actually. Here's all the steps used to initialize my new conda environment:

conda -create -n mynewenv
conda activate mynewenv
conda install pytorch cudatoolkit=10.1 -c pytorch
pip install xgboost tensorboardX ray[tune] rich guildai miceforest
conda install pytorch-lightning -c conda-forge
conda install pyarrow orange3 scikit-learn numpy pandas tqdm

@Borda
Copy link
Member

Borda commented Mar 8, 2021

@davzaman I do not see how you install bolts...

@davzaman
Copy link
Author

davzaman commented Mar 8, 2021

Oh I'm so sorry i completely missed that line!pip install pytorch-lightning-bolts (so I installed with pip, but I guess my previous comment is for reference of my env overall)

@Borda
Copy link
Member

Borda commented Mar 8, 2021

ok, can you try pip install https://github.com/PyTorchLightning/pytorch-lightning-bolts/archive/master.zip

@davzaman
Copy link
Author

davzaman commented Mar 8, 2021

I created a new env and instead of pip install pytorch-lightning-bolts I ran what you suggested and tried importing the MNISTDataModule and it did not produce errors.

@Borda Borda closed this as completed Mar 8, 2021
@Borda
Copy link
Member

Borda commented Mar 8, 2021

so it was fixed with #579

@Borda Borda added bug Something isn't working and removed fix fixing issues... labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants