Azure / Azure/azure-cli

cannot import name 'Identity' from partially initialized module 'azure.cli.core.auth.identity' (most likely due to a circular import)

Open
#28,808 1 comment 0 reactions 2 assignees Claimed by @zhoxing-ms View on GitHub
act-observability-squad Auto-Assign Azure CLI Team Compute customer-reported potential-pruning question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

Circular import randomly
```
"cannot import name 'Identity' from partially initialized module 'azure.cli.core.auth.identity'
"cannot import name 'BinaryCache' from partially initialized module 'azure.cli.core.auth.binary_cache'
"cannot import name 'RequestsTransport' from partially initialized module 'azure.core.pipeline.transport._requests_basic'
```

### Related command
```
az vm start --ids /subscriptions/xxxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxx/providers/Microsoft.Compute/virtualMachines/xxxxxxxxxx /subscriptions/xxxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxx/providers/Microsoft.Compute/virtualMachines/xxxxxxxxxx --no-wait
```

### Errors
```
"cannot import name 'Identity' from partially initialized module 'azure.cli.core.auth.identity'
"cannot import name 'BinaryCache' from partially initialized module 'azure.cli.core.auth.binary_cache'
"cannot import name 'RequestsTransport' from partially initialized module 'azure.core.pipeline.transport._requests_basic'
```

### Issue script & Debug output

n/a

### Expected behavior

no error

### Environment Summary

(azure-cli-venv) root@2ea9794aadff:/# az --version
azure-cli 2.59.0

core 2.59.0
telemetry 1.1.0

Dependencies:
msal 1.27.0
azure-mgmt-resource 23.1.0b2

Python location '/root/azure-cli-venv/bin/python3'
Extensions directory '/root/.azure/cliextensions'

Python (Linux) 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]

### Additional context

Installed in a virtualenv via pip install azure-cli
Note that there is no error if only one ID is given to the command

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.