ImportError: cannot import name 'DataShareAccount' from 'azure.mgmt.datashare.models

Prabhakaran Haribaskar 0 Reputation points
2023-02-17T13:33:01.1533333+00:00
I am trying to get data share details in azure portal under Storage service using Azure python SDK

**Error i am getting mentioned below ** 

ImportError: cannot import name 'DataShareAccount' from 'azure.mgmt.datashare.models.

Code i used to get the required information

from azure.identity import DefaultAzureCredential
from azure.mgmt.datashare import DataShareManagementClient 
from azure.mgmt.datashare.models import DataShareAccount

subscription_id = 'e5c4d6
resource_group_name = 'Prabhak
account_name = 'prabh***34'
credential = DefaultAzureCredential()
client = DataShareManagementClient(credential, subscription_id)
data_share_account = client.data_share_accounts.get(resource_group_name, account_name)
data_shares = client.data_shares.list_by_account(resource_group_name, account_name)
for data_share in data_shares:
    print(data_share.name)

Steps i have followed to overcome this error:
i tried to install required dependencies using command pip install azure.mgmt.datashare.models
Below error i am getting 
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement azure.mgmt.datashare.models (from versions: none)
ERROR: No matching distribution found for azure.mgmt.datashare.models
Azure Data Share
Azure Data Share
An Azure service that is used to share data from multiple sources with other organizations.
55 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 38,456 Reputation points Microsoft Employee
    2023-02-22T08:59:18.8966667+00:00

    Hi Prabhakaran Haribaskar,

    Thank you for posting this query in Microsoft Q&A Platform.

    This error indicates that package azure.mgmt.datashare is not installed in your environment. Kindly try below steps.

    You can install the package by running the following command in your terminal or command prompt:

    pip install azure-mgmt-datashare
    
    

    If above not helps, then try updating the package by running the following command:

    pip install --upgrade azure-mgmt-datashare
    
    

    If above not helps, then try uninstalling and reinstalling the package by running the following commands:

    pip uninstall azure-mgmt-datashare 
    pip install azure-mgmt-datashare
    
    

    If above not helps, then try installing the package using a different version by running the following command:

    pip install azure-mgmt-datashare=={version}
    
    

    If above not helps, then installing the package using a different package manager, such as conda, by running the following command.

    conda install azure-mgmt-datashare
    
    

    Hope this helps. Please let me know how it goes.


    Please consider hitting Accept Answer button. Accepted answers help community as well.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.