I am making a python app and one of it's functions involves copying the contents of one directory to several different locations. Some of these files are copied to the same directory in which they currently reside and are renamed. It almost always works except when it hit this one particular file.
This is the code that does the copying.
shutil.copy(original_path_and_file,os.path.join(redun.path, redun.file_name))
The particular copy that causes the crash is when it's trying to copy /Users/<myusername>/Desktop/archive1/test_2_here/myproject/liboqs.dylib
to /Users/<myusername>/Desktop/archive1/test_2_here/myproject/liboqs.0.dylib
This is the error that appears in my terminal:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/<myusername>/Desktop/archive1/test_2_here/myproject/liboqs.dylib'
Why does this file throw the error and none of the other files that it copies throw any errors?
Update
The way I fixed this was by having the app ignore link files. I wrote this:
if not os.path.islink(original_path_and_file):
shutil.copy(original_path_and_file,os.path.join(redun.path, redun.file_name))
This is technically more of a work-around than a fix because it doesn't actually copy the file but I decided the app still works fine when not copying link files.