If the file or directory is locked by another process, you can try closing the process or waiting for it to finish before running the Python program again.