我在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)
参数iam_api_key
已在版本1.7.1中重命名为iam_apikey
。在这个Github issue有一些讨论。