-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Describe the bug
On my dev machine, I've been getting the following error since around the first week of November 2024. It doesn't block all CLI operations (I can perform az login without issue although I do see a bunch of "Error loading command module" errors for all of my installed extensions). It does block me being able to ssh into a VM in my account, which hasn't been a blocker until today.
File "C:\Users\***\.azure\cliextensions\ssh\azext_ssh\custom.py", line 19, in <module>
from . import ip_utils
File "C:\Users\***\.azure\cliextensions\ssh\azext_ssh\ip_utils.py", line 8, in <module>
from azure.mgmt.core.tools import parse_resource_id
File "C:\Python\envs\services_py312\Lib\site-packages\azure\mgmt\core\tools.py", line 29, in <module>
from azure.core import AzureClouds
ImportError: cannot import name 'AzureClouds' from 'azure.core' (C:\Python\envs\services_py312\Lib\site-packages\azure\core\__init__.py)
I'm seeing this blocking error when I try to run:
az ssh vm --resource-group "my-RG-name" --vm-name "my-VM-name"
My environment (should all be up to date package versions)
azure-core==1.32.0
azure-cli==2.67.0
Preliminary google searching finds similar ImportError reports for different packages but not any exact matches on my issue, and I could not find any previous issues filed in this repo that match what I'm seeing.
This may be a circular dependency issue or something wrong with my environment setup, but I'm stumped and haven't found anyone running into the same issue
Related command
any 'az' command. For example: 'az login' or 'az ssh vm'
Errors
The command failed with an unexpected error. Here is the traceback:
cannot import name 'AzureClouds' from 'azure.core' (C:\Python\envs\services_py312\Lib\site-packages\azure\core_init_.py)
Traceback (most recent call last):
File "C:\Python\envs\services_py312\Lib\site-packages\knack\cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands_init_.py", line 564, in execute
self.commands_loader.load_arguments(command)
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core_init_.py", line 526, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands_init_.py", line 321, in load_arguments
super(AzCliCommand, self).load_arguments()
File "C:\Python\envs\services_py312\Lib\site-packages\knack\commands.py", line 104, in load_arguments
cmd_args = self.arguments_loader()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands\command_operation.py", line 125, in arguments_loader
op = self.get_op_handler(self.op_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands\command_operation.py", line 59, in get_op_handler
handler = import_module(mod_to_import)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\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 995, in exec_module
File "", line 488, in call_with_frames_removed
File "C:\Users***.azure\cliextensions\ssh\azext_ssh\custom.py", line 19, in
from . import ip_utils
File "C:\Users\patha.azure\cliextensions\ssh\azext_ssh\ip_utils.py", line 8, in
from azure.mgmt.core.tools import parse_resource_id
File "C:\Python\envs\services_py312\Lib\site-packages\azure\mgmt\core\tools.py", line 29, in
from azure.core import AzureClouds
ImportError: cannot import name 'AzureClouds' from 'azure.core' (C:\Python\envs\services_py312\Lib\site-packages\azure\core_init.py)
Issue script & Debug output
cli.knack.cli: Command arguments: ['ssh', 'vm', '--resource-group', 'KnowledgeGraph', '--vm-name', 'Neo4j-enterprise', '--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 0x00000237F845F100>, <function OutputProducer.on_global_arguments at 0x00000237F85A1F80>, <function CLIQuery.on_global_arguments at 0x00000237F85E34C0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'ssh': ['azext_ssh']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: Total (0) 0.000 0 0
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.azure.cli.core: ssh 0.691 1 4 C:\Users\patha.azure\cliextensions\ssh
cli.azure.cli.core: Total (1) 0.691 1 4
cli.azure.cli.core: Loaded 1 groups, 4 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : ssh vm
cli.azure.cli.core: Command table: ssh vm
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x00000237FA9CBBA0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\patha.azure\commands\2024-12-06.16-30-51.ssh_vm.24256.log'.
az_command_data_logger: command args: ssh vm --resource-group {} --vm-name {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x00000237FAA1F420>]
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "C:\Python\envs\services_py312\Lib\site-packages\knack\cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands_init_.py", line 564, in execute
self.commands_loader.load_arguments(command)
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core_init_.py", line 526, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands_init_.py", line 321, in load_arguments
super(AzCliCommand, self).load_arguments()
File "C:\Python\envs\services_py312\Lib\site-packages\knack\commands.py", line 104, in load_arguments
cmd_args = self.arguments_loader()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands\command_operation.py", line 125, in arguments_loader
op = self.get_op_handler(self.op_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands\command_operation.py", line 59, in get_op_handler
handler = import_module(mod_to_import)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\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 995, in exec_module
File "", line 488, in call_with_frames_removed
File "C:\Users\patha.azure\cliextensions\ssh\azext_ssh\custom.py", line 19, in
from . import ip_utils
File "C:\Users\patha.azure\cliextensions\ssh\azext_ssh\ip_utils.py", line 8, in
from azure.mgmt.core.tools import parse_resource_id
File "C:\Python\envs\services_py312\Lib\site-packages\azure\mgmt\core\tools.py", line 29, in
from azure.core import AzureClouds
ImportError: cannot import name 'AzureClouds' from 'azure.core' (C:\Python\envs\services_py312\Lib\site-packages\azure\core_init.py)
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: cannot import name 'AzureClouds' from 'azure.core' (C:\Python\envs\services_py312\Lib\site-packages\azure\core_init_.py)
Traceback (most recent call last):
File "C:\Python\envs\services_py312\Lib\site-packages\knack\cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands_init_.py", line 564, in execute
self.commands_loader.load_arguments(command)
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core_init_.py", line 526, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands_init_.py", line 321, in load_arguments
super(AzCliCommand, self).load_arguments()
File "C:\Python\envs\services_py312\Lib\site-packages\knack\commands.py", line 104, in load_arguments
cmd_args = self.arguments_loader()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands\command_operation.py", line 125, in arguments_loader
op = self.get_op_handler(self.op_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands\command_operation.py", line 59, in get_op_handler
handler = import_module(mod_to_import)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\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 995, in exec_module
File "", line 488, in call_with_frames_removed
File "C:\Users\patha.azure\cliextensions\ssh\azext_ssh\custom.py", line 19, in
from . import ip_utils
File "C:\Users\patha.azure\cliextensions\ssh\azext_ssh\ip_utils.py", line 8, in
from azure.mgmt.core.tools import parse_resource_id
File "C:\Python\envs\services_py312\Lib\site-packages\azure\mgmt\core\tools.py", line 29, in
from azure.core import AzureClouds
ImportError: cannot import name 'AzureClouds' from 'azure.core' (C:\Python\envs\services_py312\Lib\site-packages\azure\core_init.py)
az_command_data_logger: cannot import name 'AzureClouds' from 'azure.core' (C:\Python\envs\services_py312\Lib\site-packages\azure\core_init.py)
Traceback (most recent call last):
File "C:\Python\envs\services_py312\Lib\site-packages\knack\cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands_init.py", line 564, in execute
self.commands_loader.load_arguments(command)
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core_init.py", line 526, in load_arguments
self.command_table[command].load_arguments() # this loads the arguments via reflection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands_init.py", line 321, in load_arguments
super(AzCliCommand, self).load_arguments()
File "C:\Python\envs\services_py312\Lib\site-packages\knack\commands.py", line 104, in load_arguments
cmd_args = self.arguments_loader()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands\command_operation.py", line 125, in arguments_loader
op = self.get_op_handler(self.op_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\site-packages\azure\cli\core\commands\command_operation.py", line 59, in get_op_handler
handler = import_module(mod_to_import)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\envs\services_py312\Lib\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 995, in exec_module
File "", line 488, in call_with_frames_removed
File "C:\Users\patha.azure\cliextensions\ssh\azext_ssh\custom.py", line 19, in
from . import ip_utils
File "C:\Users\patha.azure\cliextensions\ssh\azext_ssh\ip_utils.py", line 8, in
from azure.mgmt.core.tools import parse_resource_id
File "C:\Python\envs\services_py312\Lib\site-packages\azure\mgmt\core\tools.py", line 29, in
from azure.core import AzureClouds
ImportError: cannot import name 'AzureClouds' from 'azure.core' (C:\Python\envs\services_py312\Lib\site-packages\azure\core_init.py)
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 0x00000237FA9CBE20>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 1.482 seconds (init: 0.444, invoke: 1.039)
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 7663 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "C:\Python\envs\services_py312\python.exe C:\python\envs\services_py312\Lib\site-packages\azure\cli\telemetry_init.py C:\Users\patha.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.
Expected behavior
I expect to be able to connect to my VM through an ssh terminal session.
Environment Summary
azure-cli 2.67.0
core 2.67.0
telemetry 1.1.0
Extensions:
containerapp 1.1.0b1
ssh 2.0.6
Dependencies:
msal 1.31.0
azure-mgmt-resource 23.1.1
Python location 'C:\Python\envs\services_py312\python.exe'
Extensions directory 'C:\Users\patha.azure\cliextensions'
Python (Windows) 3.12.7 | packaged by Anaconda, Inc. | (main, Oct 4 2024, 13:17:27) [MSC v.1929 64 bit (AMD64)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Additional context
No response