pytorch_tabular icon indicating copy to clipboard operation
pytorch_tabular copied to clipboard

Install Issues: 'get_num_classes' from 'torchmetrics.utilities.data'

Open VRM1 opened this issue 3 years ago • 3 comments

When installing package via the pip command, I end up getting the following error when executing from pytorch_tabular import TabularModel. I am doing a clean install and no other packages were installed prior to your package. It looks like there is some version conflict between Pytorch lightning and your package.

ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (/Users/vineeth/anaconda3/envs/pytorchtabular/lib/python3.9/site-packages/torchmetrics/utilities/data.py).

I tried to remove the 0.9.x version of torchmetrics (that was installed by default when using your pip command) and install 0.7.x, which resolved the above issue, but now I get a different issue with the following error:

ImportError: cannot import name 'RichProgressBar' from 'pytorch_lightning.callbacks'

Could be please help me in resolving this issue?

Thanks

VRM1 avatar Aug 17 '22 23:08 VRM1

ImportError: cannot import name 'RichProgressBar' from 'pytorch_lightning.callbacks'

I'm assuming you are using the latest main branch from GitHub because RichProgressBar was not in any of the PyPi ones.

Which version of PyTorch Lightning are you using?

manujosephv avatar Aug 18 '22 05:08 manujosephv

I have the same issue, and I ran the tutorial on Google Colab Pro

Update: you should try to run !pip uninstall -y torchtext before install pytorch_tabular.

Source

tudoanh avatar Aug 19 '22 15:08 tudoanh

@tudoanh Uninstalling torchtext doesn't work. Moreover, I am getting an error like this - `ImportError Traceback (most recent call last)

in 5 import pickle 6 tf.random.set_seed(1234) ----> 7 from torchmetrics.utilities import get_num_classes as _get_num_classes

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

shubhamc-iiitd avatar Aug 23 '22 08:08 shubhamc-iiitd

The solution is to install PyTorch Lightning through mamba / conda, and get rid of the pip dependency. pip installs an old version.

NicoPiel avatar Sep 19 '22 16:09 NicoPiel

Thanks for the suggestion @NicoPiel. On Colab I tried installing Lightning using conda and I still get the original error on from pytorch_tabular import TabularModel:

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

ryanmark1867 avatar Oct 29 '22 21:10 ryanmark1867

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 17 '23 06:01 stale[bot]

This confusion should be over with v1.0.* All dependencies have been upgraded

manujosephv avatar Jan 19 '23 11:01 manujosephv