azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

Error running az apim command

Open Spyntek opened this issue 7 years ago • 16 comments

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az apim show

Errors:

No module named 'azure.mgmt.apimanagement.models.api_management_client_enums'
Traceback (most recent call last):
pip-install-qxmmnr17\knack\knack\cli.py, ln 206, in invoke
cli\core\commands\__init__.py, ln 523, in execute
azure\cli\core\__init__.py, ln 291, in load_arguments
cli\core\commands\__init__.py, ln 290, in load_arguments
pip-install-qxmmnr17\knack\knack\commands.py, ln 97, in load_arguments
cli\core\commands\arm.py, ln 709, in generic_show_arguments_loader
...
<frozen importlib._bootstrap_external>, ln 678, in exec_module
<frozen importlib._bootstrap>, ln 219, in _call_with_frames_removed
cli\command_modules\apim\custom.py, ln 9, in <module>
ModuleNotFoundError: No module named 'azure.mgmt.apimanagement.models.api_management_client_enums'

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 apim show

Expected Behavior

Environment Summary

Windows-10-10.0.18975-SP0
Python 3.6.6
Shell: powershell.exe

azure-cli 2.0.72
azure-cli-iot-ext 0.7.1

Extensions:
alias 0.5.2
azure-cli-iot-ext 0.7.1
azure-devops 0.12.0
interactive 0.4.3
storage-preview 0.2.7
vm-repair 0.1.1
webapp 0.2.19

Additional Context

Spyntek avatar Sep 10 '19 18:09 Spyntek

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @mjconnection

ghost avatar Sep 11 '19 02:09 ghost

I'm getting the same error. My version info:

> azure-cli                         2.0.73
> 
> command-modules-nspkg               2.0.3
> core                              2.0.73
> nspkg                              3.0.4
> telemetry                          1.0.3
> 
> Extensions:
> application-insights               0.1.1
> 
> Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
> Extensions directory 'C:\Users\MarcDuiker\.azure\cliextensions'
> 
> Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]
> 
> Legal docs and information: aka.ms/AzureCliLegal
> 
> 
> Your CLI is up-to-date.

marcduiker avatar Sep 12 '19 10:09 marcduiker

I'm getting the same error. My version info:

> azure-cli                         2.0.73
> 
> command-modules-nspkg               2.0.3
> core                              2.0.73
> nspkg                              3.0.4
> telemetry                          1.0.3
> 
> Extensions:
> application-insights               0.1.1
> 
> Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
> Extensions directory 'C:\Users\MarcDuiker\.azure\cliextensions'
> 
> Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]
> 
> Legal docs and information: aka.ms/AzureCliLegal
> 
> 
> Your CLI is up-to-date.

Yes, I just updated my az cli to 2.0.73 and am still receiving the same error

Spyntek avatar Sep 12 '19 13:09 Spyntek

The custom.py file seems to reference a file called azure\mgmt\apimanagement\models\api_management_client_enums.py however if we look in the azure\mgmt\apimanagement\models directory we see that the file is actually called _api_management_client_enums.py.

Removing the underscore in the filename seems to work. But in order to not break anything else I advice you to copy the file and remove the underscore from the copy, so that programs that reference the file with the underscore don't break.

Disclaimer: I'm not familiar with the source, but this is a work around until it is officially fixed. I wouldn't use this in any production environment.

@ the azure team,
In the custom.py file, shouldn't the line

from azure.mgmt.apimanagement.models.api_management_client_enums import VirtualNetworkType, SkuType

just be

from azure.mgmt.apimanagement.models import VirtualNetworkType, SkuType

?
Those two classes are already exposed by the init file.

jurgyy avatar Sep 16 '19 14:09 jurgyy

@jurgyy ,

I can't find a file called custom.py in my machine. Where do you find it?

Mine is referring to a path where it is not there at all. This user doesn't exist C:\Users\VSSADM~1

az apim show
The command failed with an unexpected error. Here is the traceback:

No module named 'azure.mgmt.apimanagement.models.api_management_client_enums'
Traceback (most recent call last):
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-6e754znd\knack\knack\cli.py", line 206, in invoke
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-6e754znd\azure-cli-core\azure\cli\core\commands\__init__.py", line 523, in execute
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-6e754znd\azure-cli-core\azure\cli\core\__init__.py", line 291, in load_arguments
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-6e754znd\azure-cli-core\azure\cli\core\commands\__init__.py", line 291, in load_arguments
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-6e754znd\knack\knack\commands.py", line 97, in load_arguments
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-6e754znd\azure-cli-core\azure\cli\core\commands\arm.py", line 709, in generic_show_arguments_loader
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-6e754znd\azure-cli-core\azure\cli\core\commands\arm.py", line 390, in get_arguments_loader
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-6e754znd\azure-cli-core\azure\cli\core\__init__.py", line 528, in get_op_handler
  File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-6e754znd\azure-cli\azure\cli\command_modules\apim\custom.py", line 9, in <module>
ModuleNotFoundError: No module named 'azure.mgmt.apimanagement.models.api_management_client_enums'

wshamroukh-zz avatar Sep 25 '19 13:09 wshamroukh-zz

@wshamroukh I don't think you should edit the custom.pyc file, since it's a compiled python file, but it's file location for me is is C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\command_modules\apim\.

For the work-around you can find the api_management_client_enums file in C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\mgmt\apimanagement\models\

jurgyy avatar Sep 26 '19 07:09 jurgyy

@wshamroukh I don't think you should edit the custom.pyc file, since it's a compiled python file, but it's file location for me is is C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\command_modules\apim\.

For the work-around you can find the api_management_client_enums file in C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\mgmt\apimanagement\models\

For me not to get it working i had to have two files with the following names under C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\mgmt\apimanagement\models\:

api_management_client_enums.py
_api_management_client_enums.py

Because when I renamed the file from _api_management_client_enums.py to api_management_client_enums.py the init.py was still looking for _api_management_client_enums.py

wshamroukh-zz avatar Sep 26 '19 07:09 wshamroukh-zz

Great that it works, but that's exactly what I said in my earlier comment ;)

But in order to not break anything else I advice you to copy the file and remove the underscore from the copy, so that programs that reference the file with the underscore don't break.

jurgyy avatar Sep 26 '19 09:09 jurgyy

When should we expect a fix for this issue?

Spyntek avatar Oct 01 '19 12:10 Spyntek

@MyronFanQiu has accepted my PR and has since been moved to the release branch, right? So this issue could be marked as solved.

jurgyy avatar Nov 27 '19 13:11 jurgyy

@jurgyy Yes. It's has been released. Feel free to re-open this one if you still meet problems.

mmyyrroonn avatar Nov 28 '19 01:11 mmyyrroonn

Same issue: azure-cli 2.0.80

command-modules-nspkg 2.0.3 core 2.0.80 nspkg 3.0.4 telemetry 1.0.4

Used workaround above: api_management_client_enums.py _api_management_client_enums.py

shuttlek avatar Jan 22 '20 10:01 shuttlek

This should be re-opened, it is still an issue with the latest release. The cloud powershell shell does not seem to be affected.

Ugenx avatar Feb 20 '20 20:02 Ugenx

@Ugenx I have open a PR to fix it. @jurgyy Hi. Looks like last time we didn't fix them all. I have created a PR, could you please review it and sign off?

mmyyrroonn avatar Feb 21 '20 01:02 mmyyrroonn

Yea, same as @Ugenx I'm still seeing this error in 2.1.0. You can reproduce it with any of the following commands:

  • az apim apply-network-updates --help
  • az apim backup --help
  • az apim check-name --help
  • az apim create --help
  • az apim delete --help
  • az apim list --help
  • az apim show --help
  • az apim update --help

lprichar avatar Feb 22 '20 15:02 lprichar

@lprichar Sure. We have fixed this one and merged a PR. The new version will be available in the next week. Currently, you can use our edge build version. https://github.com/Azure/azure-cli#edge-builds

mmyyrroonn avatar Feb 24 '20 02:02 mmyyrroonn