【问题标题】:AWS Connection error to Endpoint URL for Rekognition用于 Rekognition 的端点 URL 的 AWS 连接错误
【发布时间】:2018-07-02 19:45:01
【问题描述】:

我刚开始使用 AWS Rekognition,遇到了一个我似乎无法解决的问题。

我正在使用Detecting Text in an Image - Amazon Rekognition 上提供的 Python 脚本来测试该服务的工作方式以及我如何将其集成到其他应用程序中。

我知道我为配置和凭据文件输入了正确的数据,可在此处找到:

~/.aws/credentials

因为其他服务(例如 S3)使用命令行代码可以正常工作。在提供的代码中(我将在最后包含它)我指定了正确的存储桶以及我尝试使用的图片的名称。 运行脚本时,在终端上一切正常,直到几秒钟后显示以下错误消息:

botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint 
 URL: "https://rekognition.eu-west-2.amazonaws.com/"

我还尝试了其他几个可用区,例如:

us-east-1, us-west-1, eu-central-1

但它们都会导致相同的错误。

python - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint - Stack Overflow 已经讨论过类似的问题。但是,该讨论中提供的解决方案并没有解决我遇到的问题。我将不胜感激任何可以解决此问题的帮助和提示。

import boto3

bucket='bucket'
photo='inputtext.jpg'

client=boto3.client('rekognition')

response=client.detect_text(Image={'S3Object':{'Bucket':bucket,'Name':photo}})

textDetections=response['TextDetections']
print response
print 'Matching faces'
for text in textDetections:
        print 'Detected text:' + text['DetectedText']
        print 'Confidence: ' + "{:.2f}".format(text['Confidence']) + "%"
        print 'Id: {}'.format(text['Id'])
        if 'ParentId' in text:
            print 'Parent Id: {}'.format(text['ParentId'])
        print 'Type:' + text['Type']
        print

【问题讨论】:

    标签: python macos amazon-web-services amazon-rekognition


    【解决方案1】:

    你的代码对我来说工作得很好。

    我连接到悉尼地区:

    client=boto3.client('rekognition',region_name='ap-southeast-2')
    

    请注意supported regions for Amazon Rekognition 是(在撰写此答案时):

    • us-east-2
    • us-east-1
    • us-west-2
    • ap-southeast-2
    • ap-northeast-1
    • eu-west-1

    【讨论】:

    • 您好,我已更改为 eu-west-1 的区域,我现在收到另一个错误。但这与脚本有关。我收到的错误是:文件“text1.py”,第 11 行打印响应 ^ SyntaxError:调用“打印”时缺少括号。您是说打印(响应)吗?
    • Python 3 需要 print(xx)。 Python 2 没有。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多