Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 2.99k forks source link

import name 'CaseInsensitiveDict' from 'azure.core.utils' when installing az extension #27380

Open huliang-microsoft opened 1 year ago

huliang-microsoft commented 1 year ago

Describe the bug

Hi Azure Cli team, We are using Azure Devops to build our service and we started to see this failure when we tried to install extensions:

sudo az extension add --name quota --version 0.1.0 -y cannot import name 'CaseInsensitiveDict' from 'azure.core.utils' (/opt/az/lib/python3.10/site-packages/azure/core/utils/init.py)

We installed azure cli with: sudo apt-get install -y --allow-downgrades azure-cli=2.39.0-1~focal

The previous successful pipeline runs are also 2.39.0-1 so I dont know what changed.

Thanks

Related command

sudo az extension add --name quota --version 0.1.0 -y

Errors

cannot import name 'CaseInsensitiveDict' from 'azure.core.utils' (/opt/az/lib/python3.10/site-packages/azure/core/utils/init.py)

Issue script & Debug output

cannot import name 'CaseInsensitiveDict' from 'azure.core.utils' (/opt/az/lib/python3.10/site-packages/azure/core/utils/init.py)

Expected behavior

The package should be installed

Environment Summary

azure-cli 2.39.0-1

Additional context

No response

azure-client-tools-bot-prd[bot] commented 1 year ago

Hi @huliang-microsoft,

2.39.0 is not the latest Azure CLI(2.52.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

yonzhan commented 1 year ago

Thank you for opening this issue, we will look into it.

azure-client-tools-bot-prd[bot] commented 1 year ago
Hi @huliang-microsoft Find similar issue https://github.com/Azure/azure-cli/issues/23267.
Issue title compatibility issues between azure-core and azure-cli: cannot import name 'case_insensitive_dict' from 'azure.core.utils'
Create time 2022-07-19
Comment number 14

Possible solution: The error message "cannot import name 'CaseInsensitiveDict' from 'azure.core.utils'" is caused by compatibility issues between azure-core and azure-cli. Until cli 2.37.0, AZ CLI had the dependency azure-core==1.21.1. Starting 2.38.0, AZ CLI is having dependency azure-core==1.24.0. In case, we install a package that has a direct or indirect dependency on the lower azure-core==1.21.1, the AZ CLI encounters the compatibility issues between azure-core and azure-cli and emits the error: cannot import name 'case_insensitive_dict' from 'azure.core.utils'. To fix the issue, you can try installing azure-core==1.23.1 by running %pip install azure-core==1.23.1.


Please confirm if this resolves your issue.

microsoft-github-policy-service[bot] commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

ManuK001 commented 1 year ago

Hi @huliang-microsoft! Az 2.39 is bit old now compared 2.52. I helped resolve a similar issue recently from customer by suggesting him to "Az upgrade" and add Az ML extension after removal. Could you confirm it from your side.

  1. az upgrade
  2. az extension remove -n azure-cli-ml
  3. az extension remove -n ml
  4. az extension add -n ml

Reference - https://github.com/Azure/azure-cli/issues/21390 Thank you.

microsoft-github-policy-service[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @v-anvashist, @V-hmusukula.