Hi I imported through conda using:
conda create -n scvi-env python=3.9
when importing in jupyter I use
import scvi
I get an import error with pytorch_lightning:
ImportError: cannot import name ‘get_num_classes’ from ‘torchmetrics.utilities.data’
Full error message:
ImportError Traceback (most recent call last)
Cell In [3], line 1
----> 1 import scvi
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\scvi_init_.py:7
4 import logging
6 from ._constants import _CONSTANTS
----> 7 from ._settings import settings
9 # this import needs to come after prior imports to prevent circular import
10 from . import data, model, external, utils
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\scvi_settings.py:5
2 from pathlib import Path
3 from typing import Union
----> 5 import pytorch_lightning as pl
6 import torch
7 from rich.console import Console
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pytorch_lightning_init_.py:20
17 _PACKAGE_ROOT = os.path.dirname(file)
18 _PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT)
—> 20 from pytorch_lightning import metrics # noqa: E402
21 from pytorch_lightning.callbacks import Callback # noqa: E402
22 from pytorch_lightning.core import LightningDataModule, LightningModule # noqa: E402
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pytorch_lightning\metrics_init_.py:15
1 # Copyright The PyTorch Lightning team.
2 #
3 # Licensed under the Apache License, Version 2.0 (the “License”);
(…)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
—> 15 from pytorch_lightning.metrics.classification import ( # noqa: F401
16 Accuracy,
17 AUC,
18 AUROC,
19 AveragePrecision,
20 ConfusionMatrix,
21 F1,
22 FBeta,
23 HammingDistance,
24 IoU,
25 Precision,
26 PrecisionRecallCurve,
27 Recall,
28 ROC,
29 StatScores,
30 )
31 from pytorch_lightning.metrics.metric import Metric, MetricCollection # noqa: F401
32 from pytorch_lightning.metrics.regression import ( # noqa: F401
33 ExplainedVariance,
34 MeanAbsoluteError,
(…)
39 SSIM,
40 )
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pytorch_lightning\metrics\classification_init_.py:14
1 # Copyright The PyTorch Lightning team.
2 #
3 # Licensed under the Apache License, Version 2.0 (the “License”);
(…)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
—> 14 from pytorch_lightning.metrics.classification.accuracy import Accuracy # noqa: F401
15 from pytorch_lightning.metrics.classification.auc import AUC # noqa: F401
16 from pytorch_lightning.metrics.classification.auroc import AUROC # noqa: F401
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pytorch_lightning\metrics\classification\accuracy.py:18
14 from typing import Any, Callable, Optional
16 from torchmetrics import Accuracy as _Accuracy
—> 18 from pytorch_lightning.metrics.utils import deprecated_metrics, void
21 class Accuracy(_Accuracy):
22 @deprecated_metrics(target=_Accuracy)
23 def init(
24 self,
(…)
31 dist_sync_fn: Callable = None,
32 ):
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pytorch_lightning\metrics\utils.py:22
20 from torchmetrics.utilities.data import dim_zero_mean as _dim_zero_mean
21 from torchmetrics.utilities.data import dim_zero_sum as _dim_zero_sum
—> 22 from torchmetrics.utilities.data import get_num_classes as _get_num_classes
23 from torchmetrics.utilities.data import select_topk as _select_topk
24 from torchmetrics.utilities.data import to_categorical as _to_categorical
ImportError: cannot import name ‘get_num_classes’ from ‘torchmetrics.utilities.data’