Python 3.x: ImportError: can not import name 'scandir'

2

I'm trying to use the scandir module and it gives me the error: ImportError: can not import name 'scandir' . I do not understand, it is assumed that the version I am using, 3.4.4 already has this module implemented. Does anyone have any idea how I can fix it? Thank you very much.

    
asked by Mr. Baldan 06.12.2016 в 13:56
source

1 answer

4

os.scandir() is an added feature in version 3.5 of Python, it is not available for 3.4 as you can see in the official documentation .

One possible solution is to use the external module scandir installing it via pip . To do this you open the terminal (Windows CMD) and enter:

pip install scandir

If everything goes well and it is installed correctly, you import it like this:

from scandir import scandir

Another option is to use os.listdir() or os.walk() depending on your needs and if they are available in Python 3.4

    
answered by 06.12.2016 / 14:44
source