Skip to content

Az cli error 'No module named 'msrestazure''Β #31797

@julianm-lrj

Description

@julianm-lrj

Describe the bug

When running the following command, az cli errors off with the traceback: No module named 'msrestazure'

az aks list -o table

Related command

az aks list -o table

Errors

The command failed with an unexpected error. Here is the traceback:
No module named 'msrestazure'
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 564, in execute
self.commands_loader.load_arguments(command)
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/init.py", line 552, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 321, in load_arguments
super().load_arguments()
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/commands.py", line 104, in load_arguments
cmd_args = self.arguments_loader()
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 124, in arguments_loader
op = self.get_op_handler(self.op_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 59, in get_op_handler
handler = import_module(mod_to_import)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.11/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 999, in exec_module
File "", line 488, in _call_with_frames_removed
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 61, in
from azext_aks_preview._podidentity import (
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/_podidentity.py", line 16, in
from azext_aks_preview._roleassignments import add_role_assignment
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/_roleassignments.py", line 18, in
from msrestazure.azure_exceptions import CloudError
ModuleNotFoundError: No module named 'msrestazure'

Issue script & Debug output

cli.knack.cli: Command arguments: ['aks', 'list', '-o', 'table', '--debug']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x102d4b2e0>, <function OutputProducer.on_global_arguments at 0x1030b8360>, <function CLIQuery.on_global_arguments at 0x1030d9b20>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'aks': ['azext_aks_preview', 'azure.cli.command_modules.acs', 'azure.cli.command_modules.serviceconnector']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: acs 0.065 15 79
cli.azure.cli.core: serviceconnector 0.053 20 331
cli.azure.cli.core: Total (2) 0.118 35 410
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.knack.cli: Event: CommandLoader.OnLoadCommandTable []
cli.azure.cli.core: aks-preview 0.005 18 91 /Users/USERNAME/.azure/cliextensions/aks-preview
cli.azure.cli.core: Total (1) 0.005 18 91
cli.azure.cli.core: Loaded 39 groups, 434 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : aks list
cli.azure.cli.core: Command table: aks list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x104507ba0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/USERNAME/.azure/commands/2025-07-11.21-39-24.aks_list.99203.log'.
az_command_data_logger: command args: aks list -o {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x1045587c0>]
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 564, in execute
self.commands_loader.load_arguments(command)
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/init.py", line 552, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 321, in load_arguments
super().load_arguments()
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/commands.py", line 104, in load_arguments
cmd_args = self.arguments_loader()
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 124, in arguments_loader
op = self.get_op_handler(self.op_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 59, in get_op_handler
handler = import_module(mod_to_import)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.11/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 999, in exec_module
File "", line 488, in _call_with_frames_removed
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 61, in
from azext_aks_preview._podidentity import (
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/_podidentity.py", line 16, in
from azext_aks_preview._roleassignments import add_role_assignment
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/_roleassignments.py", line 18, in
from msrestazure.azure_exceptions import CloudError
ModuleNotFoundError: No module named 'msrestazure'

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
cli.azure.cli.core.azclierror: No module named 'msrestazure'
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 564, in execute
self.commands_loader.load_arguments(command)
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/init.py", line 552, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 321, in load_arguments
super().load_arguments()
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/commands.py", line 104, in load_arguments
cmd_args = self.arguments_loader()
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 124, in arguments_loader
op = self.get_op_handler(self.op_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 59, in get_op_handler
handler = import_module(mod_to_import)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.11/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 999, in exec_module
File "", line 488, in _call_with_frames_removed
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 61, in
from azext_aks_preview._podidentity import (
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/_podidentity.py", line 16, in
from azext_aks_preview._roleassignments import add_role_assignment
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/_roleassignments.py", line 18, in
from msrestazure.azure_exceptions import CloudError
ModuleNotFoundError: No module named 'msrestazure'
az_command_data_logger: No module named 'msrestazure'
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 564, in execute
self.commands_loader.load_arguments(command)
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/init.py", line 552, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 321, in load_arguments
super().load_arguments()
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/knack/commands.py", line 104, in load_arguments
cmd_args = self.arguments_loader()
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 124, in arguments_loader
op = self.get_op_handler(self.op_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 59, in get_op_handler
handler = import_module(mod_to_import)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.11/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 999, in exec_module
File "", line 488, in _call_with_frames_removed
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 61, in
from azext_aks_preview._podidentity import (
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/_podidentity.py", line 16, in
from azext_aks_preview._roleassignments import add_role_assignment
File "/Users/USERNAME/.azure/cliextensions/aks-preview/azext_aks_preview/_roleassignments.py", line 18, in
from msrestazure.azure_exceptions import CloudError
ModuleNotFoundError: No module named 'msrestazure'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x104507e20>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 0.474 seconds (init: 0.162, invoke: 0.312)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 7983 in cache file under /Users/USERNAME/.azure/telemetry/20250711213924752
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/bin/python /opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/cli/telemetry/init.py /Users/USERNAME/.azure /Users/USERNAME/.azure/telemetry/20250711213924752"
telemetry.process: Return from creating process 99208
telemetry.main: Finish creating telemetry upload process.

Expected behavior

When running the command, it is expected that the output would be a list of all the in-scoped aks clusters.

Environment Summary

azure-cli 2.75.0

core 2.75.0
telemetry 1.1.0

Extensions:
account 0.2.5
aks-preview 1.0.0b1
azure-devops 1.0.0
managementpartner 0.1.3
partnercenter 0.2.4
resource-graph 2.1.0
ssh 2.0.2

Dependencies:
msal 1.33.0b1
azure-mgmt-resource 23.3.0

Python location '/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/bin/python'
Config directory '/Users/USERNAME/.azure'
Extensions directory '/Users/USERNAME/.azure/cliextensions'

Python (Darwin) 3.12.11 (main, Jun 3 2025, 15:41:47) [Clang 17.0.0 (clang-1700.0.13.3)]

Additional context

This error began after upgrading to this version of az cli with brew

Metadata

Metadata

Assignees

No one assigned

    Labels

    AKSaz aks/acs/openshiftAuto-AssignAuto assign by botService AttentionThis issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions