azure-cli: ImportError: cannot import name 'BatchManagementClient' from 'azure.mgmt.batch'

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az network traffic-manager profile check-dns

Errors:

cannot import name 'BatchManagementClient' from 'azure.mgmt.batch' (/usr/lib/python3/dist-packages/azure/mgmt/batch/__init__.py)
Traceback (most recent call last):
python3/dist-packages/knack/cli.py, ln 231, in invoke
    cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 558, in execute
    self.commands_loader.load_arguments(command)
...
network/private_link_resource_and_endpoint_connections/resource_providers/batch_provider.py, ln 6, in <module>
    from azure.mgmt.batch import BatchManagementClient
ImportError: cannot import name 'BatchManagementClient' from 'azure.mgmt.batch' (/usr/lib/python3/dist-packages/azure/mgmt/batch/__init__.py)

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here…
  • az network traffic-manager profile check-dns {}

Expected Behavior

Environment Summary

Linux-5.10.0-kali9-amd64-x86_64-with-glibc2.31
Python 3.9.2
Installer: DEB

azure-cli 2.18.0 *

Extensions:
azure-devops 0.19.0

Additional Context

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

I noticed a weird thing. The official Azure CLI DEB installer has its bundled Python 3.6.10.

$ az -v
azure-cli                         2.27.2

core                              2.27.2
...

Python location '/opt/az/bin/python3'
Extensions directory '/home/user1/.azure/cliextensions'

Python (Linux) 3.6.10 (default, Aug 23 2021, 03:36:00)
[GCC 9.3.0]

But in all linked issues, Python is 3.9.* and Azure CLI is 2.18.0:

Linux-5.10.0-kali9-amd64-x86_64-with-glibc2.31
Python 3.9.2
Installer: DEB

azure-cli 2.18.0 *

Could you let me know the distribution of Linux you are using by running

cat /etc/os-release

Where did you install this Linux? From official installation source? From docker?

Before installing the official Azure CLI, please remove the pre-installed Azure CLI, which is not maintained by Microsoft:

sudo apt remove azure-cli -y && sudo apt autoremove -y