pytorch_tabular icon indicating copy to clipboard operation
pytorch_tabular copied to clipboard

Import Error (Again)

Open keonho-kim opened this issue 2 years ago • 1 comments

I found import error is re-occurring on Colab, seems like the same thing with @sonnguyen129's

! pip install pytorch_tabular[all]

# to restart kernel
import os; os._exit(00)  
from pytorch_tabular import TabularModel

This returns

ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (/usr/local/lib/python3.7/dist-packages/torchmetrics/utilities/data.py)

I tried to change version of torchmetric, the old one,

! pip install pytorch_tabular[all]
! pip install torchmetrics==0.3.2 
import os; os._exit(00)

this returns another depdency error. (torchtext)

/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py in <module>()
     28 if _TORCHTEXT_AVAILABLE:
     29     if _compare_version("torchtext", operator.ge, "0.9.0"):
---> 30         from torchtext.legacy.data import Batch
     31     else:
     32         from torchtext.data import Batch

ModuleNotFoundError: No module named 'torchtext.legacy'

This haapens with 0.7.1.

could you give me a solution?

keonho-kim avatar Jul 04 '22 07:07 keonho-kim

I use "pip install torchmetrics==0.5" to solve this problem of import. I'm not sure whether it will cause any other problem.

TuozhenLiu avatar Jul 26 '22 07:07 TuozhenLiu

Is there any fix for this problem ?

rt3722 avatar Aug 13 '22 15:08 rt3722

What @TuozhenLiu suggested fixes this as of now. Long term fix is in progress and will be pushed as part of the new release. It stems from the PyTorch Lightning dependency and a more stronger integration with PyTorch Lightning would resolve these kind of issues.

manujosephv avatar Aug 14 '22 02:08 manujosephv