ImportError: cannot import name '_log_class_usage' from 'torchtext.utils'

641 Views Asked by At

I recently updated pytorch and torchtext from anaconda, in order to run this tutorial from the torchtext website, but it seems that my installation of torchtext has been broken. Everytime that I try import torchtext I get the following error:

ImportError: cannot import name '_log_class_usage' from 'torchtext.utils' (c:\Users\ferdi\anaconda3\lib\site-packages\torchtext\utils.py)

Uninstalling torchtext then reinstalling with conda install -c pytorch torchtext does not help. Does anybody have an idea for how to solve it? My torch version is 1.13.0.

1

There are 1 best solutions below

0
On

I noticed there is always a specific torchtext version for the torch version and it is essential that they are aligned. According to https://pypi.org/project/torchtext/ the torchtext version you need is 0.14.0, and the latest version is 0.15.0. So if you simply do conda install -c pytorch torchtext you'd download the wrong version.