3

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?

Ethernetz
  • 906
  • 3
  • 16
  • 33
  • 1
    Possible duplicate of [Is generator.next() visible in python 3.0?](https://stackoverflow.com/questions/1073396/is-generator-next-visible-in-python-3-0) – AlokThakur Feb 18 '18 at 03:22
  • I saw that post. Am I meant to change line 730 of the actual python code? I tried it and it didn't work. – Ethernetz Feb 18 '18 at 03:26
  • 1
    Update your `tflearn` installation. The [code on github](https://github.com/tflearn/tflearn/blob/master/tflearn/data_utils.py#L754) does not have this error (or rather catches this error). How/from where did you install `tflearn`? – Patrick Haugh Feb 18 '18 at 03:27
  • Then your problem is different, you are trying to use a 3rd party module which is not working with python3, may be find correct version which support python3 – AlokThakur Feb 18 '18 at 03:28
  • Yeah, this looks like you are trying to run a Python 2 version of a library using a Python 3 interpreter – juanpa.arrivillaga Feb 18 '18 at 03:29

1 Answers1

2

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

Abhishek Raj
  • 478
  • 7
  • 17