minimaxir / aitextgen

A robust Python tool for text-based AI training and generation using GPT-2.
https://docs.aitextgen.io
MIT License
1.84k stars 220 forks source link

ImportError: cannot import name '_compare_version' from 'torchmetrics.utilities.imports' (/usr/local/lib/python3.10/dist-packages/torchmetrics/utilities/imports.py) #234

Open Kiyuma opened 1 year ago

Kiyuma commented 1 year ago

I'm using the google notebook Need to update the Lighting-AI code part, instead of:

[/usr/local/lib/python3.10/dist-packages/pytorch_lightning/callbacks/progress/rich_progress.py](https://localhost:8080/#) in <module>
     18 from typing import Any, Dict, Optional, Union
     19 
---> 20 from torchmetrics.utilities.imports import _compare_version
     21 
     22 import pytorch_lightning as pl

It surpose to be:

from lightning_utilities.core.imports import compare_version

And at the line 26 in usr/local/lib/python3.10/dist-packages/pytorch_lightning/callbacks/progress/rich_progress.py:

_RICH_AVAILABLE: bool = _package_available("rich") and _compare_version("rich", operator.ge, "10.2.2")

The "_compare_version" => "compare_version"