【问题标题】:Error while connecting to a region under a profile连接到配置文件下的区域时出错
【发布时间】:2016-03-23 07:18:10
【问题描述】:

根据文档区域也是 boto.emr.EmrConnection 类的参数,但是,在建立连接时出现以下错误: conn = boto.emr.EmrConnection(profile_name='profile_name', region='us-west-2')

init 中的文件“C:\Python27\lib\site-packages\boto-2.38.0-py2.7.egg\boto\emr\connection.py”,第 68 行 self.region.endpoint,调试, AttributeError: 'str' 对象没有属性 'endpoint'

有什么想法吗?

【问题讨论】:

    标签: python amazon-web-services boto amazon-emr


    【解决方案1】:

    该方法需要 RegionInfo 类型的区域,而不是字符串。

    所以通过boto.ec2.get_region('us-west-2') 而不是'us-west-2'

    import boto.ec2
    boto.emr.EmrConnection(profile_name='profile_name', region=boto.ec2.get_region('us-west-2'))
    

    【讨论】:

    • 或者,更好的是,只需使用 connect_to_region 函数,例如conn = boto.ec2.connect_to_region('us-west-2')
    • boto.emr.EmrConnection(region=boto.ec2.get_region('eu-west-1')) 对我不起作用。
    • @helloV 看问题好像他正在尝试连接获取 EMRConnection ec2 RegionInfo 不起作用。
    • @KunalC“似乎”?你知道他/她接受了答案吗?你“认为”他问了一个不同的问题?嗯。
    【解决方案2】:

    该方法需要 RegionInfo 所以试试:

    import boto.emr
    conn = boto.emr.connect_to_region('us-west-1')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-27
      • 2017-08-21
      • 1970-01-01
      • 2014-02-21
      • 2016-09-10
      • 2023-03-31
      • 2021-03-24
      • 1970-01-01
      相关资源
      最近更新 更多