TypeError:__ init __()得到了一个意外的关键字参数iam_api_key

问题描述 投票:0回答:1

我在Flask中遇到错误“TypeError:init()得到了一个意外的关键字参数'iam_api_key'”。实际上,在安装Flask之前,它在Python 2.7和3上运行良好。但是,现在它在Flask安装后无法使用Python 3。但是,仍在使用Python 2。

    from flask import Flask
from os.path import join, dirname
import json
app = Flask(__name__)
from watson_developer_cloud import SpeechToTextV1
@app.route('/',['GET'])

def hello_world():
    url="https://gateway-wdc.watsonplatform.net/speech-to-text/api"
    iam_api_key="IkhuCl3jbYWRJ3QV623PzX6e8715iCV6mbPA7evrD3qYHyS"
    speech_to_text = SpeechToTextV1(url=url,iam_api_key=iam_api_key)
    print (speech_to_text)
    return 'Hello, World!'
if __name__ == '__main__':
   app.run(debug = True)
python python-3.x flask
1个回答
2
投票

参数iam_api_key已在版本1.7.1中重命名为iam_apikey。在这个Github issue有一些讨论。

© www.soinside.com 2019 - 2024. All rights reserved.