Errno 2 using python shutil.py No such file or directory for file destination Errno 2 using python shutil.py No such file or directory for file destination xml xml

Errno 2 using python shutil.py No such file or directory for file destination


When I get this error it usually means that one of the folders doesn't exist.

I wrote a simple script to to test this out. In the script below the backup folder does exist but the today folder does not. When I run the script I get the same error as you.

IOError: [Errno 2] No such file or directory: 'backup/today/my_file.txt'

import shutilshutil.copy("my_file.txt", "backup/today/my_file.txt")

If all of your folders do exist I would check to make sure the permissions on them have not changed.


By default, shutil.copytree() follows (resolves) symbolic links. If the symlink is broken, it raises a No such file or directory exception. One workaround is to specify that symlinks should be copied unresolved by passing symlinks=True.