I am trying to copy some directories of zipped files from an AWS bucket to a Windows machine using Python in Eclipse (Pydev).
When I use the following command:
result = subprocess.Popen([r'aws s3 cp s3://myBucket/' + str(someInt) + '/ ' + output_dir + ' --recursive'], stdout=subprocess.PIPE)
I get an error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
However, if I paste the evaluated argument into the Windows command line, it copies the files successfully. I have also been able to execute the AWS command using R successfully:
result <- shell(paste0("aws ", "s3 ", "cp ", "s3://myBucket/", someInt, "/ ", output_dir, " --recursive"))
So, I know that the files exist and that I am able to copy them with other methods. I must be missing some simple syntax error with my Python command.
Update: Here is the working solution:
result = subprocess.Popen(['aws', 's3', 'cp', r's3://myBucket' + str(someInt) + '/', output_dir, '--recursive'], stdout=subprocess.PIPE)