watsonx.ai

 View Only
  • 1.  WML : KeyError : 'username'

    Posted Tue August 13, 2019 01:22 PM
    Edited by System Test Wed November 01, 2023 04:52 PM
    Hello,

    I'm trying to run an notebook wherein I associate it with the Watson Machine Learning service.

    I tested the call of this service with this following code:

    from watson_machine_learning_client import WatsonMachineLearningAPIClient

    #Reading credentials from file
    wml_credentials = {
    "apikey": "***",
    "iam_apikey_description": "***",
    "iam_apikey_name": "***",
    "iam_role_crn": "***",
    "iam_serviceid_crn": "***",
    "instance_id": "***",
    "url": "***"
    }

    client = WatsonMachineLearningAPIClient(wml_credentials)

    Unfortunately, I obtain an error message (KeyError: 'username', see the attachment piece).
    But, I don't find any username in the credentials of my Watson Machine Learning Service ???


    ------------------------------
    Jonathan Grimard
    ------------------------------
    ​​​​​
    #JupyterNotebooks
    #WatsonStudio
    #watson-machine-learning


  • 2.  RE: WML : KeyError : 'username'

    Posted Wed August 14, 2019 10:04 AM
    Hi Jonathan - 

    This looks like you have an older version of Watson Machine Learning Client installed, which is causing this error.  Please upgrade your Python client to at least the minimum version of 0.1.365 as documented here: https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-authentication.html 

    Hope this helps, 


    ------------------------------
    GREG FILLA
    ------------------------------



  • 3.  RE: WML : KeyError : 'username'

    Posted Wed August 14, 2019 10:05 AM
    Hello Jonathan,

    The issue is most likely with the version of the `watson_machine_learning_client` library. Upgrading it to a new version should solve the issue. Run the following code in your Python notebook.

    !pip install watson_machine_learning_client --upgrade
    from watson_machine_learning_client import WatsonMachineLearningAPIClient​

    Rest of the code should work as expected after that. Are you using Python Notebooks with or without Spark?



    Sumit Goyal

    ------------------------------
    Sumit Goyal
    ------------------------------