pytorch_tabular
pytorch_tabular copied to clipboard
Import Error (Again)
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?
I use "pip install torchmetrics==0.5" to solve this problem of import. I'm not sure whether it will cause any other problem.
Is there any fix for this problem ?
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.