shutil.rmtree raises "OSError: [Errno 39] Directory not empty" exception
Tim Chase
python.list at tim.thechases.com
Fri Jul 10 20:10:03 EDT 2009
> shutil.rmtree(filename)
> File "/usr/lib64/python2.5/shutil.py", line 178, in rmtree
> onerror(os.rmdir, path, sys.exc_info())
> File "/usr/lib64/python2.5/shutil.py", line 176, in rmtree
> os.rmdir(path)
> OSError: [Errno 39] Directory not empty: /path/to/my/dir
>
> According to the documentation, shutil.rmtree should not care about
> directory being not empty.
This sounds suspiciously like a permission issue. rmtree()
*should* walk the tree removing items *if it can*. If a file
can't be deleted, it treats it as an error. rmtree() takes
parameters for ignore_errors and an onerror callback function, so
you can catch these error conditions.
-tkc
More information about the Python-list
mailing list