繁体   English   中英

运行 aws s3 cp 时子进程出错:[Errno 2] 没有这样的文件或目录:'aws'

[英]Getting error with subprocess while running aws s3 cp: [Errno 2] No such file or directory: 'aws'

我能够从命令行成功执行此命令,并将所需的 csv 复制到 s3 存储桶aws s3 cp /Users/kaswani/tips.csv s3://dplearn/

但是,当我尝试使用子进程从 python 中运行相同的内容时,它会抛出错误: subprocess.check_output subprocess.check_output(['aws','s3','cp','/Users/kaswani/tips.csv','s3://dplearn/'])

错误:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/kaswani/anaconda/envs/aws/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/Users/kaswani/anaconda/envs/aws/lib/python3.5/subprocess.py", line 693, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/kaswani/anaconda/envs/aws/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/Users/kaswani/anaconda/envs/aws/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'aws'

我一直无法调试它。 Subprocess 适用于 ls 等基本命令

使用,shell=True 是可行的,即 subprocess.check_output(['aws','s3','cp','/Users/kaswani/tips.csv','s3://dplearn/'], shell=真的)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM