Cannot import torchtext (libtorchtext.so: undefined symbol)

After installing torchext, I get the following error when trying to import anything from it

OSError: <path>/anaconda3/envs/py311/lib/python3.11/site-packages/torchtext/lib/libtorchtext.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs

According this this report, it could be a compatibility issues. So have check the requirements here, which seem to match my installation when checking with conda list:

...
pytorch                   2.3.0           py3.11_cuda11.8_cudnn8.7.0_0    pytorch
...
torchtext                 0.18.0                    py311    pytorch
...

Not sure how to approach this issue further. Everything I found online was referring to problems due to mismatching versions.

Yes, these issues are indeed usually caused by mismatched versions. Just to confirm before I try to reproduce it: are you seeing this error while simply importing torchtext?

1 Like

I’ve just checked again, and now it seems working. So odd, I still have the screenshot from the error and I didn’t change anything after that. Not sure where I misses something, maybe I did not restart the kernel in Jupyter appropriately.

In any case, now I get the warning

Torchtext is deprecated and the last released version will be 0.18 (this one)

so there’s no use to stick with it anymore. Probably old news, but I rarely find some time to code anything myself, so I’ve never noticed.