'iterator' object has no attribute 'next' in python 3.7
I'm trying to iterate through my data set and get the first element
    transform = transforms.Compose([transforms.ToTensor(),transforms.Normalize((0.5),(0.5)),])
    trainloader = datasets.MNIST('~/.pytorch/MNIST_data' , download=True,train=True , transform=transform)
    ds = iter(trainloader)
    img, labels = ds.next()

but it returns this error
    AttributeError: 'iterator' object has no attribute 'next'

I also tried this
    img , labels = next(ds)

returned this error
    StopIteration:

Did I miss something ?

If you follow the tutorial on https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html

trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
                                        download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=4,
                                          shuffle=True, num_workers=2)

dataiter = iter(trainloader)
images, labels = dataiter.next()


You are missing the DataLoader() function on your dataset
