zjunlp / OpenUE

[EMNLP 2020] OpenUE: An Open Toolkit of Universal Extraction from Text
http://openue.zjukg.org
MIT License
321 stars 61 forks source link

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

Closed PeikaiLi closed 2 years ago

PeikaiLi commented 2 years ago
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 commented 2 years ago

it can be solved by update to new version

PeikaiLi commented 2 years ago

solution: pip install --upgrade pytorch-lightning