我正在尝试运行使用IBM Watson服务的示例代码。在根据需要设置我的用户名/密码或IAM密钥后,代码失败。在Python中,是这样的错误:
init ()获得了意外的关键字参数'iam_apikey'
是什么原因?我需要更改什么?
答案 0 :(得分:0)
似乎您在Watson SDK中遇到了问题。最近,他们在Python SDK V4中发现了Node SDK V5和Python的重大变化(Node,release notes)。有一种新的,更抽象的身份验证机制可以满足不同的身份验证类型。您需要稍微更改一下如何初始化NLC的代码。
这来自Python migration instructions:
例如,传递IAM apikey:
之前
from ibm_watson import MyService
service = MyService(
iam_apikey='{apikey}',
url='{url}'
)
之后(V4.0)
from ibm_watson import MyService
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
authenticator = IAMAuthenticator('{apikey}')
service = MyService(
authenticator=authenticator
)
service.set_service_url('{url}')
请参见IBM Cloud core SDKs for more documentation中的一些内容,例如,这是核心Node SDK的Authentication doc。