Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'generator' object has no attribute 'next'

Using python 3.6, I import image_preloader from tflearn.data_utils

I then write

X, Y = image_preloader("\\all\\train", image_shape=(128, 128), mode='folder', categorical_labels=True, normalize=True)

There are folders with labels inside the train folder. Inside those labeled folders are images.

I get this error:

    C:\Users\Daman\.conda\envs\TF\python.exe 
    "C:/Users/Daman/PycharmProjects/Coin Classification/main.py"
    hdf5 is not supported on this machine (please install/reinstall h5py for                         
    optimal experience)
    curses is not supported on this machine (please install/reinstall curses                 
    for an optimal experience)
    Scipy not supported!
    Traceback (most recent call last):
      File "C:\Users\Daman\.conda\envs\TF\lib\site-
    packages\tflearn\data_utils.py", line 730, in directory_to_samples
        classes = sorted(os.walk(directory).next()[1])
    AttributeError: 'generator' object has no attribute 'next'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:/Users/Daman/PycharmProjects/Coin Classification/main.py", line 
    3, in <module>
        X, Y = image_preloader("\\all\\train", image_shape=(640,480), 
    mode='folder', categorical_labels=True, normalize=True)
      File "C:\Users\Daman\.conda\envs\TF\lib\site-
    packages\tflearn\data_utils.py", line 512, in image_preloader
        flags=files_extension, filter_channel=filter_channel)
      File "C:\Users\Daman\.conda\envs\TF\lib\site-
    packages\tflearn\data_utils.py", line 732, in directory_to_samples
         classes = sorted(os.walk(directory).__next__()[1])
    StopIteration

How can I resolve this error?

like image 325
Ethernetz Avatar asked Nov 18 '25 09:11

Ethernetz


1 Answers

I was dealing with the same problem, g.next() is supported by python 2, now you can use next(g) python 3

like image 156
Abhishek Avatar answered Nov 20 '25 23:11

Abhishek