No module named '__builtin__' in Ubuntu 20.04 (Canonical image)
See original GitHub issueDescribe the bug
I was trying to install the OmsAgentForLinux and enablevmaccess extensions in Ubuntu 20.04 via CLI.
Command Name
az vm extension image list
Errors:
No module named '__builtin__'
Traceback (most recent call last):
python3/dist-packages/knack/cli.py, ln 206, in invoke
cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 528, in execute
self.commands_loader.load_arguments(command)
azure/cli/core/__init__.py, ln 300, in load_arguments
loader.load_arguments(command) # this adds entries to the argument registries
cli/command_modules/vm/__init__.py, ln 31, in load_arguments
from azure.cli.command_modules.vm._params import load_arguments
...
dist-packages/antlr4/error/Errors.py, ln 5, in <module>
from antlr4.atn.Transition import PredicateTransition
dist-packages/antlr4/atn/Transition.py, ln 19, in <module>
from __builtin__ import unicode
ModuleNotFoundError: No module named '__builtin__'
To Reproduce:
Steps to reproduce the behavior. Tried any and all of the following:
sudo apt install azure-cli
- “/usr/lib/python3/dist-packages/azure/cosmos/session.py:186: SyntaxWarning: “is not” with a literal. Did you mean “!=”? if session_token is not ‘’:”
- …
az vm extension image list --location eastus --output table
- “ModuleNotFoundError: No module named ‘antlr4’”
sudo apt install python3-pip
sudo pip3 install antlr4-python2-runtime
az vm extension image list --location westus --output table
- “ModuleNotFoundError: No module named ‘
__builtin__
’”
- “ModuleNotFoundError: No module named ‘
pip3 install future
az vm extension image list --location westus --output table
- “ModuleNotFoundError: No module named ‘
__builtin__
’”
- “ModuleNotFoundError: No module named ‘
- Rinse, repeat
Expected Behavior
- It would be nice if Azure supported backups of Ubuntu 20.04
- It would be nice if the CLI worked in Ubuntu 20.04
Environment Summary
Linux-5.4.0-1010-azure-x86_64-with-glibc2.29
Python 3.8.2
Shell: bash
azure-cli 2.0.81 *
Extensions:
azure-devops 0.17.0
Additional Context
I installed Ubuntu 20.04 from a public image (Ubuntu Server 20.04 LTS - Canonical) since there appears to be no official one (?), but when I tried to enable backups, I keep getting:
Could not communicate with the VM agent for snapshot status - Snapshot VM sub task timed out
Looking under Extensions in Portal, it says “OmsAgentForLinux (unavailable)”. It seems that I have no resort but to create a new instance with 18.04 and reproduce the tedium of re-configuring and migrating everything, but I thought that I would share this failure because the CLI recommended az feedback
. I tried using the CLI to install the missing extensions (since they are inexplicably absent when I click “Add” extension from Portal).
I imagine that this will be #wontfix’d as a Canonical or Python issue, but here it is for posterity.
- I am not an expert of the following: Azure, Python, azure-cli
- I imagine that switching to Python 2 might have an impact, but I have run out of time trying to get the CLI to work.
EDIT: Repeating these steps with Python 2 yielded the same errors, and now it is recommending that I retry on Saturday:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top GitHub Comments
Here’s a workaround for those willing to use pip3:
sudo pip3 install antlr4-python3-runtime
(from https://golder.org/azure-cli-cant-find-antlr4-python-library/)The azure-cli package that comes with the Focal universe repo is a bit old and has some issues. A new Focal package is just released for azure-cli 2.6.0. Please follow https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-apt?view=azure-cli-latest to try again.