0

我正在尝试设置一个 boto3 客户端以按照此处所做的操作使用 AWS 个性化服务:

https://docs.aws.amazon.com/personalize/latest/dg/data-prep-importing.html

到目前为止,我一直忠实地遵循本教程。我已经设置了我的 s3 存储桶,并且我有一个格式正确的 csv。

我配置了我的访问和秘密令牌,并且可以在我的 s3 存储桶上成功执行基本操作,所以我认为这部分工作正常:

import s3fs
fs = s3fs.S3FileSystem()
fs.ls('personalize-service-test')
'personalize-test/data'

当我尝试创建我的服务时,事情开始失败:

import boto3
personalize = boto3.client('personalize')

---------------------------------------------------------------------------
UnknownServiceError                       Traceback (most recent call last)
<ipython-input-13-c23d30ee6bd1> in <module>
----> 1 personalize = boto3.client('personalize')

/anaconda3/envs/ds_std_3.6/lib/python3.6/site-packages/boto3/__init__.py in client(*args, **kwargs)
     89     See :py:meth:`boto3.session.Session.client`.
     90     """
---> 91     return _get_default_session().client(*args, **kwargs)
     92 
     93 

/anaconda3/envs/ds_std_3.6/lib/python3.6/site-packages/boto3/session.py in client(self, service_name, region_name, api_version, use_ssl, verify, endpoint_url, aws_access_key_id, aws_secret_access_key, aws_session_token, config)
    261             aws_access_key_id=aws_access_key_id,
    262             aws_secret_access_key=aws_secret_access_key,
--> 263             aws_session_token=aws_session_token, config=config)
    264 
    265     def resource(self, service_name, region_name=None, api_version=None,

/anaconda3/envs/ds_std_3.6/lib/python3.6/site-packages/botocore/session.py in create_client(self, service_name, region_name, api_version, use_ssl, verify, endpoint_url, aws_access_key_id, aws_secret_access_key, aws_session_token, config)
    836             is_secure=use_ssl, endpoint_url=endpoint_url, verify=verify,
    837             credentials=credentials, scoped_config=self.get_scoped_config(),
--> 838             client_config=config, api_version=api_version)
    839         monitor = self._get_internal_component('monitor')
    840         if monitor is not None:

/anaconda3/envs/ds_std_3.6/lib/python3.6/site-packages/botocore/client.py in create_client(self, service_name, region_name, is_secure, endpoint_url, verify, credentials, scoped_config, api_version, client_config)
     77             'choose-service-name', service_name=service_name)
     78         service_name = first_non_none_response(responses, default=service_name)
---> 79         service_model = self._load_service_model(service_name, api_version)
     80         cls = self._create_client_class(service_name, service_model)
     81         endpoint_bridge = ClientEndpointBridge(

/anaconda3/envs/ds_std_3.6/lib/python3.6/site-packages/botocore/client.py in _load_service_model(self, service_name, api_version)
    115     def _load_service_model(self, service_name, api_version=None):
    116         json_model = self._loader.load_service_model(service_name, 'service-2',
--> 117                                                      api_version=api_version)
    118         service_model = ServiceModel(json_model, service_name=service_name)
    119         return service_model

/anaconda3/envs/ds_std_3.6/lib/python3.6/site-packages/botocore/loaders.py in _wrapper(self, *args, **kwargs)
    130         if key in self._cache:
    131             return self._cache[key]
--> 132         data = func(self, *args, **kwargs)
    133         self._cache[key] = data
    134         return data

/anaconda3/envs/ds_std_3.6/lib/python3.6/site-packages/botocore/loaders.py in load_service_model(self, service_name, type_name, api_version)
    376             raise UnknownServiceError(
    377                 service_name=service_name,
--> 378                 known_service_names=', '.join(sorted(known_services)))
    379         if api_version is None:
    380             api_version = self.determine_latest_version(

UnknownServiceError: Unknown service: 'personalize'. Valid service names are: acm, acm-pca, alexaforbusiness, amplify, apigateway, apigatewaymanagementapi, apigatewayv2, application-autoscaling, appmesh, appstream, appsync, athena, autoscaling, autoscaling-plans, backup, batch, budgets, ce, chime, cloud9, clouddirectory, cloudformation, cloudfront, cloudhsm, cloudhsmv2, cloudsearch, cloudsearchdomain, cloudtrail, cloudwatch, codebuild, codecommit, codedeploy, codepipeline, codestar, cognito-identity, cognito-idp, cognito-sync, comprehend, comprehendmedical, config, connect, cur, datapipeline, datasync, dax, devicefarm, directconnect, discovery, dlm, dms, docdb, ds, dynamodb, dynamodbstreams, ec2, ecr, ecs, efs, eks, elasticache, elasticbeanstalk, elastictranscoder, elb, elbv2, emr, es, events, firehose, fms, fsx, gamelift, glacier, globalaccelerator, glue, greengrass, guardduty, health, iam, importexport, inspector, iot, iot-data, iot-jobs-data, iot1click-devices, iot1click-projects, iotanalytics, kafka, kinesis, kinesis-video-archived-media, kinesis-video-media, kinesisanalytics, kinesisanalyticsv2, kinesisvideo, kms, lambda, lex-models, lex-runtime, license-manager, lightsail, logs, machinelearning, macie, marketplace-entitlement, marketplacecommerceanalytics, mediaconnect, mediaconvert, medialive, mediapackage, mediastore, mediastore-data, mediatailor, meteringmarketplace, mgh, mobile, mq, mturk, neptune, opsworks, opsworkscm, organizations, pi, pinpoint, pinpoint-email, pinpoint-sms-voice, polly, pricing, quicksight, ram, rds, rds-data, redshift, rekognition, resource-groups, resourcegroupstaggingapi, robomaker, route53, route53domains, route53resolver, s3, s3control, sagemaker, sagemaker-runtime, sdb, secretsmanager, securityhub, serverlessrepo, servicecatalog, servicediscovery, ses, shield, signer, sms, sms-voice, snowball, sns, sqs, ssm, stepfunctions, storagegateway, sts, support, swf, textract, transcribe, transfer, translate, waf, waf-regional, workdocs, worklink, workmail, workspaces, xray

实际上,列表中缺少服务名称“个性化”。

我已经尝试升级boto3botocore他们的最新版本并重新启动我的内核。

boto3           1.9.143 
botocore        1.12.143

关于下一步尝试什么的任何想法都会很棒。

4

3 回答 3

3

您是否通过登录页面注册了预览版?Personalize 仍处于有限预览阶段,因此您的帐户将无法通过boto3默认访问它,除非另外列入白名单。

编辑:个性化目前是公开的,所以这个答案不再相关。

于 2019-05-07T16:17:44.830 回答
3

The boto3 documentation does not (currently on 1.9.143) list personalize as a supported service.

于 2019-05-07T21:16:36.453 回答
0

我忽略了执行这些设置步骤:

https://docs.aws.amazon.com/personalize/latest/dg/aws-personalize-set-up-aws-cli.html

当我这样做并重新启动我的内核时,boto3 拿起了服务定义,现在一切似乎都正常了。

于 2019-05-08T13:08:55.683 回答