我在"TypeError:init()获得了一个意外的关键字参数'iam_api_key'“中得到了错误。实际上,在安装Flask之前,它在Python2.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)发布于 2018-09-13 09:33:40
参数iam_api_key已在1.7.1版本中重命名为iam_apikey。在这个Github问题上有一些讨论。
https://stackoverflow.com/questions/52310731
复制相似问题