shutil.rmtree raises "OSError: [Errno 39] Directory not empty" exception

Maria Liukis liukis at
Sat Jul 11 01:28:06 CEST 2009


Has anybody seen an exception "OSError: [Errno 39] Directory not  
empty" raised by shutil.rmtree? The code that raised an exception  
creates a lot of directories with files, and then removes them. I got  
an exception when one of such directories was removed. Here is the  

   File "/usr/lib64/python2.5/", line 178, in rmtree
     onerror(os.rmdir, path, sys.exc_info())
   File "/usr/lib64/python2.5/", line 176, in rmtree
OSError: [Errno 39] Directory not empty: /path/to/my/dir

According to the documentation, shutil.rmtree should not care about  
directory being not empty.

Thanks for the help,
liukis at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list