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

ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' #25

Closed
PeikaiLi opened this issue May 8, 2022 · 2 comments

Comments

@PeikaiLi
Copy link

PeikaiLi commented May 8, 2022

Traceback (most recent call last):
  File "main.py", line 7, in <module>
    import pytorch_lightning as pl
  File "/home/users/peikaili/.conda/envs/openue/lib/python3.8/site-packages/pytorch_lightning/__init__.py", line 20, in <module>
    from pytorch_lightning import metrics  # noqa: E402
  File "/home/users/peikaili/.conda/envs/openue/lib/python3.8/site-packages/pytorch_lightning/metrics/__init__.py", line 15, in <module>
    from pytorch_lightning.metrics.classification import (  # noqa: F401
  File "/home/users/peikaili/.conda/envs/openue/lib/python3.8/site-packages/pytorch_lightning/metrics/classification/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.classification.accuracy import Accuracy  # noqa: F401
  File "/home/users/peikaili/.conda/envs/openue/lib/python3.8/site-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.utils import deprecated_metrics
  File "/home/users/peikaili/.conda/envs/openue/lib/python3.8/site-packages/pytorch_lightning/metrics/utils.py", line 22, in <module>
    from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' 

Just follow the readme file and show this error

@PeikaiLi
Copy link
Author

PeikaiLi commented May 8, 2022

it can be solved by update to new version

@PeikaiLi PeikaiLi closed this as completed May 8, 2022
@PeikaiLi
Copy link
Author

PeikaiLi commented May 8, 2022

solution:
pip install --upgrade pytorch-lightning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant