Issue with importing pytorch lightning: torchtext.legacy error

717 views Asked by At

I've been trying many versions and combinations of versions, but I get a different error every time. Currently, this is the code I have:

!pip install transformers
!pip install pytorch-lightning==1.2.3
!pip install datasets
!pip install "torchmetrics<0.7"

import json
from datasets import load_dataset
import pandas as pd
import numpy as np
from pathlib import Path
from torch.utils.data import Dataset, DataLoader
import pytorch_lightning as pl
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers import TensorBoardLogger

Error:

ModuleNotFoundError: No module named 'torchtext.legacy'

Solutions I've tried based on other StackOverflow titles:

Various versions of torchtext and pytorch-lightning

Importing torch and torch.utils directly:

import torch
from torch import utils

Note that I think this is a Colab issue because I got it working on another cluster.

0

There are 0 answers