Import Error to Scandal

I am trying to use the scandir package as an alternative os.walkin python 2.7. However, the import ImportErroris created as follows.

Python 2.7.12 (default, Jul  1 2016, 15:12:24) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> from scandir import scandir, walk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "scandir.py", line 2, in <module>
    from scandir import walk
ImportError: cannot import name walk

I could not find any links to this error (except for cyclic import) after a thorough search and a complete stop at this point. Any help is much appreciated!

+4
source share
1 answer

You have the scandir.py file in the current working directory.

rename it and let scandir in sys.path do its magic.

0
source

Source: https://habr.com/ru/post/1656754/


All Articles