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 to start: ModuleNotFoundError: No module named 'prompt_toolkit.interface' #24213

Closed
dagnello opened this issue Oct 14, 2022 · 8 comments · Fixed by #24268
Labels
Auto-Assign Auto assign by bot 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. feature-request Interactive az interactive
Milestone

Comments

@dagnello
Copy link

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name
az interactive

Errors:

The command failed with an unexpected error. Here is the traceback:
No module named 'prompt_toolkit.interface'
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.41.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/homebrew/Cellar/azure-cli/2.41.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.41.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/homebrew/Cellar/azure-cli/2.41.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/homebrew/Cellar/azure-cli/2.41.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.41.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/homebrew/Cellar/azure-cli/2.41.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/interactive/custom.py", line 41, in start_shell
    azext_interactive.start_shell(cmd, style=style)
  File "/Users/davide.agnello/.azure/cliextensions/interactive/azext_interactive/__init__.py", line 10, in start_shell
    from .azclishell.app import AzInteractiveShell
  File "/Users/davide.agnello/.azure/cliextensions/interactive/azext_interactive/azclishell/app.py", line 33, in <module>
    from prompt_toolkit.interface import Application, CommandLineInterface
ModuleNotFoundError: No module named 'prompt_toolkit.interface'

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 interactive

Expected Behavior

Environment Summary

macOS-12.5.1-arm64-arm-64bit, Darwin 21.6.0
Python 3.10.8
Installer: HOMEBREW

azure-cli 2.41.0

Extensions:
interactive 0.4.5

Dependencies:
msal 1.20.0b1
azure-mgmt-resource 21.1.0b1

Additional Context

@ghost ghost added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot Interactive az interactive labels Oct 14, 2022
@ghost ghost assigned jiasli Oct 14, 2022
@ghost ghost added this to the Backlog milestone Oct 14, 2022
@yonzhan yonzhan added Azure CLI Team The command of the issue is owned by Azure CLI team feature-request labels Oct 14, 2022
@yonzhan
Copy link
Collaborator

yonzhan commented Oct 14, 2022

This is the parent issue of 'az interactive'

@taoyama
Copy link
Contributor

taoyama commented Oct 15, 2022

same here

@taoyama
Copy link
Contributor

taoyama commented Oct 15, 2022

Environment Summary

Linux-5.15.68.1-microsoft-standard-WSL2-x86_64-with-glibc2.35, CBL-Mariner/Linux
Python 3.9.14
Installer: RPM

azure-cli 2.41.0

Extensions:
interactive 0.4.5

Dependencies:
msal 1.20.0b1
azure-mgmt-resource 21.1.0b1

@taoyama
Copy link
Contributor

taoyama commented Oct 15, 2022

@jiasli

prompt_toolkit module is installed under /usr/lib64/az/lib/python3.9/site-packages/ by azure-cli 2.41.0 package.

$ PYTHONPAPYTHONPATH=/usr/lib64/az/lib/python3.9/site-packages/ /usr/bin/python3.9 \
-c "import sys; sys.path; import prompt_toolkit; import prompt_toolkit.interface"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'prompt_toolkit.interface'

Remove it will fix the issue.

$ sudo rm -rf /usr/lib64/az/lib/python3.9/site-packages/prompt_toolkit

$ az interactive
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

az>>

@bebound
Copy link
Contributor

bebound commented Oct 17, 2022

In #22459, mycli is added in dependency, which requires prompt-toolkit.
azure-cli installs 3.0.31 and interactive wants 1.0.18, so the conflict occurs.

@dagnello
Copy link
Author

@jiasli

prompt_toolkit module is installed under /usr/lib64/az/lib/python3.9/site-packages/ by azure-cli 2.41.0 package.

$ PYTHONPAPYTHONPATH=/usr/lib64/az/lib/python3.9/site-packages/ /usr/bin/python3.9 \
-c "import sys; sys.path; import prompt_toolkit; import prompt_toolkit.interface"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'prompt_toolkit.interface'

Remove it will fix the issue.

$ sudo rm -rf /usr/lib64/az/lib/python3.9/site-packages/prompt_toolkit

$ az interactive
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

az>>

@taoyama your suggestion worked, thanks!

@bebound bebound changed the title az interactive failed to start az interactive failed to start No module named 'prompt_toolkit.interface' Oct 17, 2022
@bebound bebound reopened this Oct 17, 2022
@bebound
Copy link
Contributor

bebound commented Oct 18, 2022

interactive uses an ancient version of prompt_toolkit which is not compatible with latest cli.

As a workaround, you need to uninstall prompt-toolkit from azure-cli. This may break other command, use it at your own risk.
For yum user, following taoyama's solution above.
For apt user, /opt/az/bin/python3 -m pip uninstall prompt_toolkit

@bebound bebound closed this as completed Oct 18, 2022
taoyama added a commit to taoyama/azure-cli that referenced this issue Oct 18, 2022
With current implementation, module path for extension is appended by sys.append().
Some module like interactive need old module so we need to prioritize to import modules under extension's directory instead of default directory.
This patch will fix problem like Azure#24213
@jiasli jiasli removed their assignment Nov 1, 2022
@seligj95 seligj95 unpinned this issue Dec 7, 2022
avgale pushed a commit to avgale/azure-cli that referenced this issue Aug 24, 2023
…ql-flexible`: Resolve dependency conflict with `interactive` extension (Azure#24268)

* fix dependency issue

* fix setup dependency

* revert other changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot 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. feature-request Interactive az interactive
Projects
None yet
5 participants