2017-02-27 62 views
1

从Windows命令行发出AWS-CLI命令"aws s3 ls"时,它成功完成。当我尝试使用R和Eclipse的shell(paste0("aws ", "s3 ", "ls"))时,它成功完成。使用RStudio找不到AWS-CLI凭证,但在Windows CLI下正常工作

然而,使用相同的凭据,从Windows命令行另一台机器上,"aws s3 ls"成功完成,但RStudio shell(paste0("aws ", "s3 ", "ls"))我得到:

"fatal error: Unable to locate credentials"

如果我从RStudio运行shell(paste0("aws ", "s3 ", "ls ", "--debug"))我得到:

2017-02-27 15:07:10,516 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env 2017-02-27 15:07:10,516 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role 2017-02-27 15:07:10,516 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file 2017-02-27 15:07:10,516 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: config-file 2017-02-27 15:07:10,516 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: ec2-credentials-file 2017-02-27 15:07:10,516 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: boto-config 2017-02-27 15:07:10,516 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: container-role 2017-02-27 15:07:10,516 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: iam-role 2017-02-27 15:07:10,520 - MainThread - botocore.vendored.requests.packages.urllib3.connectionpool - INFO - Starting new HTTP connection (1): xxx.xxx.xxx.xxx 2017-02-27 15:07:10,523 - MainThread - botocore.utils - DEBUG - Caught exception while trying to retrieve credentials: ('Connection aborted.', error(10051, 'A socket operation was attempted to an unreachable network')) Traceback (most recent call last): File "botocore\utils.pyc", line 159, in _get_request File "botocore\vendored\requests\api.pyc", line 69, in get File "botocore\vendored\requests\api.pyc", line 50, in request File "botocore\vendored\requests\sessions.pyc", line 465, in request File "botocore\vendored\requests\sessions.pyc", line 573, in send File "botocore\vendored\requests\adapters.pyc", line 415, in send

对于Windows命令行的成功案例,它找到如下所示的凭据:

2017-02-27 15:07:03,267 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env 2017-02-27 15:07:03,267 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role 2017-02-27 15:07:03,267 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file 2017-02-27 15:07:03,267 - MainThread - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials

所以,我想弄清楚为什么AWS CLI无法使用RStudio找到凭据,但它可以在Windows CLI下正常工作。

更新:我已经在两台机器上安装了Eclipse,它工作正常。但是,它仍然不适用于RStudio,因此它必须是IDE相关的问题。有任何想法吗?

+1

你可以尝试,而不是使用[** ** aws.s3(https://cran.r-project.org /package=aws.s3)软件包,它为您提供了一个到S3的本地R接口。 – Thomas

+0

谢谢你的建议。不幸的是,我不再在这个项目上工作,也无法尝试。看起来像一个不错的选择。 – Jeff

回答

1

我能够通过定义AWS凭据RStudio解决这个问题:

Sys.setenv ("AWS_ACCESS_KEY_ID" = "YourKEY_ID", 
      "AWS_SECRET_ACCESS_KEY" = "YOURSECRETACCESSKEY", 
      "AWS_DEFAULT_REGION" = "eu-west-1") 
相关问题