Skip to content

No module named "distutils" output #31398

@katmnsn

Description

@katmnsn

Describe the bug

When I open an ephemeral cloud shell session, and type az --help I see the following: No module named 'distutils' printed.

This is causing our az commands to fail in unexpected ways. We use output from az commands to capture string output and the error message "No module named 'distutils'" is prepended to the string output. An example of this is an attempt we made to capture a connection string that ended up looking like this:
"No module named 'distutils' {connection string here}"

You can reproduce this error easily by typing az --help in cloud shell.

This happens with multiple az commands, not just --help.

Image

Related command

az --help

Errors

No module named 'distutils'

Issue script & Debug output

cli.knack.cli: Command arguments: ['--help', '--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 0x7fdcfbf260c0>, <function OutputProducer.on_global_arguments at 0x7fdcfbc237e0>, <function CLIQuery.on_global_arguments at 0x7fdcfbc64d60>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: No module found from index for '['--help', '--debug']'
cli.azure.cli.core: Loading all modules and extensions
cli.azure.cli.core: Discovered command modules: ['acr', 'acs', 'advisor', 'ams', 'apim', 'appconfig', 'appservice', 'aro', 'backup', 'batch', 'batchai', 'billing', 'botservice', 'cdn', 'cloud', 'cognitiveservices', 'compute_recommender', 'computefleet', 'config', 'configure', 'consumption', 'container', 'containerapp', 'cosmosdb', 'databoxedge', 'dls', 'dms', 'eventgrid', 'eventhubs', 'extension', 'feedback', 'find', 'hdinsight', 'identity', 'interactive', 'iot', 'keyvault', 'lab', 'managedservices', 'maps', 'marketplaceordering', 'monitor', 'mysql', 'netappfiles', 'network', 'policyinsights', 'privatedns', 'profile', 'rdbms', 'redis', 'relay', 'resource', 'role', 'search', 'security', 'servicebus', 'serviceconnector', 'servicefabric', 'signalr', 'sql', 'sqlvm', 'storage', 'synapse', 'util', 'vm']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: acr 0.131 36 149
cli.azure.cli.core: acs 0.014 15 79
cli.azure.cli.core: advisor 0.001 3 6
cli.azure.cli.core: ams 0.004 22 100
cli.azure.cli.core: apim 0.004 14 69
cli.azure.cli.core: appconfig 0.003 9 47
cli.azure.cli.core: appservice 0.017 80 277
cli.azure.cli.core: aro 0.006 1 10
cli.azure.cli.core: backup 0.003 16 60
cli.azure.cli.core: batch 0.052 32 96
cli.azure.cli.core: batchai 0.002 10 30
cli.azure.cli.core: billing 0.009 19 53
cli.azure.cli.core: botservice 0.002 12 42
cli.azure.cli.core: cdn 0.112 8 50
cli.azure.cli.core: cloud 0.001 1 7
cli.azure.cli.core: cognitiveservices 0.002 10 33
cli.azure.cli.core: compute_recommender 0.002 1 1
cli.azure.cli.core: computefleet 0.006 1 1
cli.azure.cli.core: config 0.001 2 7
cli.azure.cli.core: configure 0.001 2 5
cli.azure.cli.core: consumption 0.011 8 9
cli.azure.cli.core: container 0.006 2 17
cli.azure.cli.core: containerapp 0.075 37 123
cli.azure.cli.core: cosmosdb 0.010 58 200
cli.azure.cli.core: databoxedge 0.005 5 28
cli.azure.cli.core: dls 0.002 6 36
cli.azure.cli.core: dms 0.001 3 22
cli.azure.cli.core: eventgrid 0.005 25 96
cli.azure.cli.core: eventhubs 0.008 14 21
cli.azure.cli.core: extension 0.001 1 7
cli.azure.cli.core: feedback 0.001 1 2
cli.azure.cli.core: find 0.001 1 1
cli.azure.cli.core: hdinsight 0.004 9 42
cli.azure.cli.core: identity 0.001 2 11
cli.azure.cli.core: interactive 0.000 1 1
cli.azure.cli.core: iot 0.077 19 82
cli.azure.cli.core: keyvault 0.007 20 113
cli.azure.cli.core: lab 0.061 9 30
cli.azure.cli.core: managedservices 0.007 3 8
cli.azure.cli.core: maps 0.002 5 13
cli.azure.cli.core: marketplaceordering 0.002 1 2
cli.azure.cli.core: monitor 0.406 18 61
cli.azure.cli.core: mysql 0.061 16 56
cli.azure.cli.core: netappfiles 0.033 8 17
cli.azure.cli.core: network 0.109 104 345
cli.azure.cli.core: policyinsights 0.009 9 17
cli.azure.cli.core: privatedns 0.015 14 60
cli.azure.cli.core: profile 0.001 2 8
cli.azure.cli.core: rdbms 0.156 53 223
cli.azure.cli.core: redis 0.003 7 38
cli.azure.cli.core: relay 0.017 7 8
cli.azure.cli.core: resource 0.014 52 232
cli.azure.cli.core: role 0.003 17 62
cli.azure.cli.core: search 0.005 7 19
cli.azure.cli.core: security 0.009 48 98
cli.azure.cli.core: servicebus 0.006 13 17
cli.azure.cli.core: serviceconnector 0.056 20 323
cli.azure.cli.core: servicefabric 0.010 27 80
cli.azure.cli.core: signalr 0.003 10 42
cli.azure.cli.core: sql 0.012 56 215
cli.azure.cli.core: sqlvm 0.017 4 20
cli.azure.cli.core: storage 0.048 60 275
cli.azure.cli.core: synapse 0.010 54 246
cli.azure.cli.core: util 0.001 3 7
cli.azure.cli.core: vm 0.072 59 219
cli.azure.cli.core: Total (65) 1.737 1192 4674
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: ai-examples 0.054 1 1 /usr/lib/python3.12/site-packages/azure-cli-extensions/ai-examples
azext_mlv2.manual.vendored_curated_sdk.azure.ai.ml._azure_environments: Using the default cloud configuration: 'AzureCloud'.
azext_mlv2.manual.vendored_curated_sdk.azure.ai.ml._azure_environments: Using the default cloud configuration: 'AzureCloud'.
azext_mlv2.manual.vendored_curated_sdk.azure.ai.ml._azure_environments: Using the default cloud configuration: 'AzureCloud'.
No module named 'distutils'
cli.azure.cli.core: ml 3.183 25 165 /usr/lib/python3.12/site-packages/azure-cli-extensions/ml
cli.azure.cli.core: ssh 0.008 1 4 /usr/lib/python3.12/site-packages/azure-cli-extensions/ssh
cli.azure.cli.core: Total (3) 3.245 27 170
cli.azure.cli.core: Loaded 1205 groups, 4844 commands.
cli.azure.cli.core: Updated command index in 0.007 seconds.
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7fdcfad647c0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/kat/.azure/commands/2025-05-01.23-55-51.unknown_command.6563.log'.
az_command_data_logger: command args: --help --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x7fdcfadbcea0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x7fdcfac08180>, <function register_cache_arguments..add_cache_arguments at 0x7fdcfac082c0>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x7fdcfac08360>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [<function _documentdb_deprecate at 0x7fdcf92202c0>]

Group
az

Subgroups:
account : Manage Azure subscription information.
acr : Manage private registries with Azure Container Registries.
ad : Manage Microsoft Entra ID (formerly known as Azure Active
Directory, Azure AD, AAD) entities needed for Azure role-based
access control (Azure RBAC) through Microsoft Graph API.
advisor : Manage Azure Advisor.
afd : Manage Azure Front Door Standard/Premium.
ai-examples [Preview] : Add AI powered examples to help content.
aks : Manage Azure Kubernetes Services.
ams : Manage Azure Media Services resources.
apim : Manage Azure API Management services.
appconfig : Manage App Configurations.
appservice : Manage App Service plans.
aro : Manage Azure Red Hat OpenShift clusters.
backup : Manage Azure Backups.
batch : Manage Azure Batch.
bicep : Bicep CLI command group.
billing : Manage Azure Billing.
bot : Manage Microsoft Azure Bot Service.
cache : Commands to manage CLI objects cached using the --defer
argument.
capacity : Manage capacity.
cdn : Manage Azure Content Delivery Networks (CDNs).
cloud : Manage registered Azure clouds.
cognitiveservices : Manage Azure Cognitive Services accounts.
compute-fleet [Preview] : Manage for Azure Compute Fleet.
compute-recommender [Preview] : Manage sku/zone/region recommender info for compute
resources.
config [Experimental] : Manage Azure CLI configuration.
connection : Commands to manage Service Connector local connections which
allow local environment to connect Azure Resource. If you want
to manage connection for compute service, please run 'az
webapp/containerapp/spring connection'.
consumption [Preview] : Manage consumption of Azure resources.
container : Manage Azure Container Instances.
containerapp : Manage Azure Container Apps.
cosmosdb : Manage Azure Cosmos DB database accounts.
data-boundary : Data boundary operations.
databoxedge [Preview] : Manage device with databoxedge.
deployment : Manage Azure Resource Manager template deployment at
subscription scope.
deployment-scripts : Manage deployment scripts at subscription or resource group
scope.
disk : Manage Azure Managed Disks.
disk-access : Manage disk access resources.
disk-encryption-set : Disk Encryption Set resource.
dls [Preview] : Manage Data Lake Store accounts and filesystems.
dms : Manage Azure Data Migration Service (classic) instances.
eventgrid : Manage Azure Event Grid topics, domains, domain topics, system
topics partner topics, event subscriptions, system topic event
subscriptions and partner topic event subscriptions.
eventhubs : Eventhubs.
extension : Manage and update CLI extensions.
feature : Manage resource provider features.
functionapp : Manage function apps. To install the Azure Functions Core tools
see https://github.com/Azure/azure-functions-core-tools.
group : Manage resource groups and template deployments.
hdinsight : Manage HDInsight resources.
identity : Managed Identities.
image : Manage custom virtual machine images.
iot : Manage Internet of Things (IoT) assets.
keyvault : Manage KeyVault keys, secrets, and certificates.
lab [Preview] : Manage azure devtest labs.
lock : Manage Azure locks.
logicapp : Manage logic apps.
managed-cassandra : Azure Managed Cassandra.
managedapp : Manage template solutions provided and maintained by Independent
Software Vendors (ISVs).
managedservices : Manage the registration assignments and definitions in Azure.
maps : Manage Azure Maps.
mariadb : Manage Azure Database for MariaDB servers.
ml
monitor : Manage the Azure Monitor Service.
mysql : Manage Azure Database for MySQL servers.
netappfiles : Manage Azure NetApp Files (ANF) Resources.
network : Manage Azure Network resources.
policy : Manage resource policies.
postgres : Manage Azure Database for PostgreSQL servers.
ppg : Manage Proximity Placement Groups.
private-link : Private-link association CLI command group.
provider : Manage resource providers.
redis : Manage dedicated Redis caches for your Azure applications.
relay : Manage Azure Relay Service namespaces, WCF relays, hybrid
connections, and rules.
resource : Manage Azure resources.
resourcemanagement : Resourcemanagement CLI command group.
restore-point : Manage restore point with res.
role : Manage Azure role-based access control (Azure RBAC).
search : Manage Azure Search services, admin keys and query keys.
security : Manage your security posture with Microsoft Defender for Cloud.
servicebus : Servicebus.
sf : Manage and administer Azure Service Fabric clusters.
sig : Manage shared image gallery.
signalr : Manage Azure SignalR Service.
snapshot : Manage point-in-time copies of managed disks, native blobs, or
other snapshots.
sql : Manage Azure SQL Databases and Data Warehouses.
ssh : SSH into resources (Azure VMs, Arc servers, etc) using AAD
issued openssh certificates.
sshkey : Manage ssh public key with vm.
stack : A deployment stack is a native Azure resource type that enables
you to perform operations on a resource collection as an atomic
unit.
staticwebapp : Manage static apps.
storage : Manage Azure Cloud Storage resources.
synapse : Manage and operate Synapse Workspace, Spark Pool, SQL Pool.
tag : Tag Management on a resource.
term [Experimental] : Manage marketplace agreement with marketplaceordering.
ts : Manage template specs at subscription or resource group scope.
vm : Manage Linux or Windows virtual machines.
vmss : Manage groupings of virtual machines in an Azure Virtual Machine
Scale Set (VMSS).
webapp : Manage web apps.

Commands:
configure : Manage Azure CLI configuration. This command is interactive.
feedback : Send feedback to the Azure CLI Team.
find : I'm an AI robot, my advice is based on our Azure documentation
as well as the usage patterns of Azure CLI and Azure ARM users.
Using me improves Azure products and documentation.
interactive [Preview] : Start interactive mode. Installs the Interactive
extension if not installed already.
login : Log in to Azure.
logout : Log out to remove access to Azure subscriptions.
rest : Invoke a custom request.
survey : Take Azure CLI survey.
upgrade [Preview] : Upgrade Azure CLI and extensions.
version : Show the versions of Azure CLI modules and extensions in JSON
format by default or format configured by --output.

To search AI knowledge base for examples, use: az find "az "

cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fdcfad64a40>]
az_command_data_logger: exit code: 0
cli.main: Command ran in 5.264 seconds (init: 0.139, invoke: 5.125)
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 3887 in cache file under /home/kat/.azure/telemetry/20250501235551521
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/usr/bin/python3.12 /usr/lib/az/lib/python3.12/site-packages/azure/cli/telemetry/init.py /home/kat/.azure /home/kat/.azure/telemetry/20250501235551521"
telemetry.process: Return from creating process 6572
telemetry.main: Finish creating telemetry upload process.

Expected behavior

No output

Environment Summary

azure-cli 2.71.0

core 2.71.0
telemetry 1.1.0

Extensions:
ai-examples 0.2.5
ml 2.36.0
ssh 2.0.6

Dependencies:
msal 1.31.2b1
azure-mgmt-resource 23.1.1

Python location '/usr/bin/python3.12'
Config directory '/home/kat/.azure'
Extensions directory '/home/kat/.azure/cliextensions'
Extensions system directory '/usr/lib/python3.12/site-packages/azure-cli-extensions'

Python (Linux) 3.12.9 (main, Mar 11 2025, 15:30:57) [GCC 13.2.0]

Additional context

No response

Metadata

Metadata

Assignees

Labels

AADAuto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamPossible-SolutionSimilar-IssuequestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions