我正在运行此命令:
AWS_PROFILE=sandbox aws s3 cp local_path bucket --recursive
这很好用。我想运行python脚本。这是我的代码:
cmd = ['AWS_PROFILE=sandbox', 'aws', 's3', 'cp', local_path, bucket, '--recursive']
subprocess.Popen(cmd).communicate()
但它不起作用。
错误回溯:
File "bin/run_report.py", line 128, in main
subprocess.Popen(cmd).communicate()
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 390, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1025, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
我不明白我做错了什么。我已经三次检查了到本地和到bucket的路径,如前所述,它是从shell运行的(我不想运行shell=True)