首页 > 解决方案 > TypeError: __init__() got an unexpected keyword argument iam_api_key

问题描述

I am getting the errors in Flask of "TypeError: init() got an unexpected keyword argument 'iam_api_key'". Actually, it was working fine with Python 2.7 and 3 before installing Flask. But, now it is not working with Python 3 after Flask installation. But, still working using 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)

标签: pythonpython-3.xflask

解决方案


该参数iam_api_keyiam_apikey在版本 1.7.1 中重命名为。在这个Github issue上有一些讨论。


推荐阅读