Search code examples
azureazure-aksazure-container-serviceazure-python-sdk

Azure.mgmt.containerservice.ContainerServiceClient import fails with No module named 'azure.mgmt'


I am working on automating certain tasks related to Azure Kubernetes.

For this, I want to connect to AKS to list pods and to get live logs which we get through kubectl.

However, when I import the azure module as follows

from azure.mgmt.containerservice import ContainerServiceClient

or

from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient

It throws exception that

ModuleNotFoundError: No module named 'azure.mgmt'

I have properly installed this module in virtual env which gets listed on the pip3 list.

Is there any new way of working with AKS or container service?

Edit - Output of pip3 list is -

Package                            Version
---------------------------------- ---------
azure-common                       1.1.28
azure-core                         1.26.3
azure-identity                     1.12.0
azure-mgmt-core                    1.3.2
azure-mgmt-kubernetesconfiguration 2.0.0

Solution

  • The problem is solved for me for the time being i.e. I am no more seeing the error.

    What I did? --> Used VS Code rather than Pycharm IDE where I was getting error.

    Workaround or solution? --> This is workaround. i.e. I could manage to make it working for me and proceed with my implementation.

    So problem seems to be with Pycharm IDE and not sure what's the solution for it.

    Any suggestions to solve this Pycharm problem is most welcome. (I will mark that answer as accepted, in that case.)