Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

az interactive fails with python 3.12 #8171

Closed
orkisz opened this issue Oct 21, 2024 · 6 comments · Fixed by #8186
Closed

az interactive fails with python 3.12 #8171

orkisz opened this issue Oct 21, 2024 · 6 comments · Fixed by #8186
Assignees
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. extension/interactive question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@orkisz
Copy link

orkisz commented Oct 21, 2024

Describe the bug

After updating brew packages, which caused setting default python3 instance to python3.13, az interactive stopped to work

Related command

az interactive

Errors

This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
The command failed with an unexpected error. Here is the traceback:
'ConfigParser' object has no attribute 'readfp'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/command_modules/interactive/custom.py", line 41, in start_shell
    azext_interactive.start_shell(cmd, style=style)
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/__init__.py", line 11, in start_shell
    AzInteractiveShell(cmd.cli_ctx, style)()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/azclishell/app.py", line 111, in __init__
    self.config = Configuration(cli_ctx.config, style=style)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/azclishell/configuration.py", line 76, in __init__
    self.config.readfp(config_file)  # pylint: disable=deprecated-method
    ^^^^^^^^^^^^^^^^^^
AttributeError: 'ConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Issue script & Debug output

cli.knack.cli: Command arguments: ['interactive', '--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 0x102ef60c0>, <function OutputProducer.on_global_arguments at 0x1031f6de0>, <function CLIQuery.on_global_arguments at 0x1032385e0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'interactive': ['azure.cli.command_modules.interactive']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: interactive               0.001         1         1
cli.azure.cli.core: Total (1)                 0.001         1         1
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: Total (0)                 0.000         0         0
cli.azure.cli.core: Loaded 1 groups, 1 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : interactive
cli.azure.cli.core: Command table: interactive
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x104771260>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/ko/.azure/commands/2024-10-21.10-22-33.interactive.12563.log'.
az_command_data_logger: command args: interactive --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x1047bed40>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x1047e5080>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x1047e51c0>, <function register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x1047e5260>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x1031f6e80>, <function CLIQuery.handle_query_parameter at 0x103238680>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x1047e5120>]
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/command_modules/interactive/custom.py", line 41, in start_shell
    azext_interactive.start_shell(cmd, style=style)
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/__init__.py", line 11, in start_shell
    AzInteractiveShell(cmd.cli_ctx, style)()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/azclishell/app.py", line 111, in __init__
    self.config = Configuration(cli_ctx.config, style=style)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/azclishell/configuration.py", line 76, in __init__
    self.config.readfp(config_file)  # pylint: disable=deprecated-method
    ^^^^^^^^^^^^^^^^^^
AttributeError: 'ConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?

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: 'ConfigParser' object has no attribute 'readfp'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/command_modules/interactive/custom.py", line 41, in start_shell
    azext_interactive.start_shell(cmd, style=style)
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/__init__.py", line 11, in start_shell
    AzInteractiveShell(cmd.cli_ctx, style)()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/azclishell/app.py", line 111, in __init__
    self.config = Configuration(cli_ctx.config, style=style)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/azclishell/configuration.py", line 76, in __init__
    self.config.readfp(config_file)  # pylint: disable=deprecated-method
    ^^^^^^^^^^^^^^^^^^
AttributeError: 'ConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?
az_command_data_logger: 'ConfigParser' object has no attribute 'readfp'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/lib/python3.12/site-packages/azure/cli/command_modules/interactive/custom.py", line 41, in start_shell
    azext_interactive.start_shell(cmd, style=style)
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/__init__.py", line 11, in start_shell
    AzInteractiveShell(cmd.cli_ctx, style)()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/azclishell/app.py", line 111, in __init__
    self.config = Configuration(cli_ctx.config, style=style)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ko/.azure/cliextensions/interactive/azext_interactive/azclishell/configuration.py", line 76, in __init__
    self.config.readfp(config_file)  # pylint: disable=deprecated-method
    ^^^^^^^^^^^^^^^^^^
AttributeError: 'ConfigParser' object has no attribute 'readfp'. Did you mean: 'read'?
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 0x1047714e0>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 0.302 seconds (init: 0.120, invoke: 0.182)

Expected behavior

Expect az interactive to start interactive session

Environment Summary

azure-cli                         2.65.0

core                              2.65.0
telemetry                          1.1.0

Extensions:
azure-devops                       1.0.1
interactive                        0.5.3
logic                              1.1.0
ml                                2.31.0

Dependencies:
msal                              1.31.0
azure-mgmt-resource               23.1.1

Python location '/opt/homebrew/Cellar/azure-cli/2.65.0_1/libexec/bin/python'
Extensions directory '/Users/ko/.azure/cliextensions'

Python (Darwin) 3.12.7 (main, Oct  1 2024, 02:05:46) [Clang 15.0.0 (clang-1500.3.9.4)]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

Additional context

No response

@orkisz orkisz added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Oct 21, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Oct 21, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Oct 21, 2024

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

@yonzhan yonzhan added Azure CLI Team The command of the issue is owned by Azure CLI team and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Oct 21, 2024
@yonzhan yonzhan added this to the Backlog milestone Oct 21, 2024
@orkisz
Copy link
Author

orkisz commented Oct 22, 2024

Update: issue is no longer present after updating azure-cli from 2.65.0_1 to 2.65.0_2 which reverted Python dependency back to 3.11

@ReaNAiveD
Copy link
Member

ReaNAiveD commented Oct 23, 2024

The extension interactive used ConfigParser.readfp which is no longer supported in Python 3.12. I will replace it with ConfigParser.read_file.

@bebound bebound changed the title az interactive fails with python 3.13 az interactive fails with python 3.12 Oct 23, 2024
@orkisz
Copy link
Author

orkisz commented Nov 14, 2024

Issue appeared again after updating azure-cli from 2.65.0_2 to 2.66.0. Please reopen

@ReaNAiveD
Copy link
Member

Hi @orkisz , Could you please run az --version to verify if the interactive extension has been updated to version 1.0.0b1 or newer?

@orkisz
Copy link
Author

orkisz commented Nov 15, 2024

Before the manual upgrade:

⋊> ~ az --version                                                                                                                                                                                                                   08:54:28
azure-cli                         2.66.0

core                              2.66.0
telemetry                          1.1.0

Extensions:
azure-devops                       1.0.1
interactive                        0.5.3
logic                              1.1.0
ml                                2.31.0

Dependencies:
msal                              1.31.0
azure-mgmt-resource               23.1.1

Python location '/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/bin/python'
Extensions directory '/Users/ko/.azure/cliextensions'

Python (Darwin) 3.12.7 (main, Oct  1 2024, 02:05:46) [Clang 15.0.0 (clang-1500.3.9.4)]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

After I did manual upgrade by az upgrade:

⋊> ~ az --version                                                                                                                                                                                                                   08:56:40
azure-cli                         2.66.0

core                              2.66.0
telemetry                          1.1.0

Extensions:
azure-devops                       1.0.1
interactive                      1.0.0b1
logic                              1.1.0
ml                                2.32.1

Dependencies:
msal                              1.31.0
azure-mgmt-resource               23.1.1

Python location '/opt/homebrew/Cellar/azure-cli/2.66.0/libexec/bin/python'
Extensions directory '/Users/ko/.azure/cliextensions'

Python (Darwin) 3.12.7 (main, Oct  1 2024, 02:05:46) [Clang 15.0.0 (clang-1500.3.9.4)]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date

And now it seems the problem is gone. Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. extension/interactive question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants