question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing torchtext in Kaggle notebook

See original GitHub issue

🐛 Bug

Describe the bug A clear and concise description of what the bug is.

There is a bug just by following PyTorch’s SST-2 tutorial online.

To Reproduce Steps to reproduce the behavior:

  1. Go to the demo online
  2. Just following the steps, code fails on import torchtext.transforms as T with torchtext==0.12.0
  3. Error:
----> 1 import torchtext.transforms as T
      2 from torch.hub import load_state_dict_from_url
      3 
      4 padding_idx = 1
      5 bos_idx = 0

/opt/conda/lib/python3.7/site-packages/torchtext/transforms.py in <module>
      4 import torch
      5 from torchtext.data.functional import load_sp_model
----> 6 from torchtext.utils import get_asset_local_path
      7 from torchtext.vocab import Vocab
      8 from torchtext._torchtext import GPT2BPEEncoder as GPT2BPEEncoderPyBind, CLIPEncoder as CLIPEncoderPyBind

ImportError: cannot import name 'get_asset_local_path' from 'torchtext.utils' (/opt/conda/lib/python3.7/site-packages/torchtext/utils.py)

Expected behavior

The tutorial should work as it is.

Additional context

I’m on kaggle.com

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Nayef211commented, Apr 15, 2022

So it looks like the default torchtext version in this tutorial is 0.11.0. I verified this using the following lines

import torchtext
torchtext.__version__

After installing torchtext 0.12.0 using !pip install torchtext==0.12.0, we are able to get past the code failure. @parmeet do you know how we can update the default torchtext and torch versions for this tutorial?

0reactions
maulberto3commented, Apr 16, 2022

@mthrok

Nice to know the correct combination of libraries. Will be happy to report if anything else. Thanks a lot. Lastly, hopefully this will help other people too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Usage with PyTorch and Torchtext library - Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from ... import tokenizer and pretrained word embeddings from torchtext.data.utils ...
Read more >
Pytorch | Torchtext - Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from multiple data sources.
Read more >
Using this dataset-Pytorch and torchtext - Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from IMBD sentiment ... import os import torch from torchtext import...
Read more >
Pytorch text classification : Torchtext + LSTM - Kaggle
In this notebook, We will be classifying text (The data-set used here contains ... import time import torch from torchtext import data import...
Read more >
PyTorch, TorchText, Glove - Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from multiple data sources.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found