azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

ImportError: cannot import name 'TokenCredential' from 'azure.core.credentials

Open G3gayathri opened this issue 2 years ago • 3 comments

Hi, We were trying create a python app using ms-graph SDK for python and got the following error:

from .azure_identity_access_token_provider import AzureIdentityAccessTokenProvider

File "C:\Users\Gayathri Prasad\anaconda3\envs\msgraph2\lib\site-packages\kiota_authentication_azure\azure_identity_access_token_provider.py", line 5, in from azure.core.credentials import TokenCredential ImportError: cannot import name 'TokenCredential' from 'azure.core.credentials' (C:\Users/Gayathri Prasad/AppData/Roaming/Python/Python310/site-packages\azure\core\credentials.py)

G3gayathri avatar Dec 26 '22 06:12 G3gayathri

@G3gayathri Are you referring to any sample for this ? Can you please share your code snippet where you are getting this error?

SaurabhSharma-MSFT avatar Dec 26 '22 08:12 SaurabhSharma-MSFT

I was trying to follow the tutorial provided here https://learn.microsoft.com/en-us/graph/tutorials/python?tabs=aad

G3gayathri avatar Dec 30 '22 12:12 G3gayathri

@G3gayathri I have followed the article and do not see any issues getting it run with Graph SDK package.
image Can you please check if you have installed pip install azure-identity and pip install msgraph-sdk before executing the main.py file.

SaurabhSharma-MSFT avatar Jan 03 '23 10:01 SaurabhSharma-MSFT

@G3gayathri Please let us know if you have any questions.

SaurabhSharma-MSFT avatar Jan 05 '23 03:01 SaurabhSharma-MSFT

@G3gayathri We will now proceed to close this thread. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.

SaurabhSharma-MSFT avatar Jan 06 '23 08:01 SaurabhSharma-MSFT

@SaurabhSharma-MSFT I'm having the same issue when importing defaultcredentials from the azure-ai-ml python library in an endpoint on machine learning studio. Any idea on why this happens? Haven't found any mention of the problem other than this issue...

malikaasen avatar Jan 11 '23 15:01 malikaasen

@SaurabhSharma-MSFT I'm having the same issue when importing MLClient from azure.ai.ml in an endpoint on machine learning studio. Any suggestions ?

hshujuan avatar Feb 09 '23 23:02 hshujuan

@hshujuan Refer to this, fixed the issue for me(should also be in current release) https://github.com/Azure/azure-sdk-for-python/issues/28369

malikaasen avatar Feb 10 '23 11:02 malikaasen