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__'
Steps to reproduce the behavior. Tried any and all of the following:
sudo apt install azure-cliaz vm extension image list --location eastus --output tablesudo apt install python3-pipsudo pip3 install antlr4-python2-runtimeaz vm extension image list --location westus --output table__builtin__'"_pip3 install futureaz vm extension image list --location westus --output table__builtin__'"_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
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.
EDIT: Repeating these steps with Python 2 yielded the same errors, and now it is recommending that I retry on Saturday:

Same request for me, I would like the azure-cli to offer a ubuntu 20.04 release. I tried installing the bionic version of the azure-cli instead, and it leads to errors and failures when trying to add extensions.
@qwordy please take a look
FYI - I experimented and created a new Azure instance with the standard Ubuntu 18.04 LTS image, then did a do-release-upgrade. I wanted to see if I got a different result using that method rather than the public Canonical 20.04 image, but I received the same Python error(s) with the azure-cli:
$ cat /etc/*release* | grep VERSION
VERSION="20.04 LTS (Focal Fossa)"
$ az vm extension image list
The command failed with an unexpected error. Here is the traceback:
No module named 'antlr4'
...
I tried various things (including trying to install the latest version per the documentation; 2.6.0 at the time of this writing), but failed.
If anyone stumbles across this, the Docker image _appears_ to be working (at least I'm not getting errors, though when I tried to (re-)install OmsAgentForLinux, it just hangs at "-- Running .." and I've spent _way_ too much time on this already).
# Install Docker if you don't have it
sudo apt install docker.io
# Add BASH alias so we don't need to type the long command each time
echo "alias az='docker run -u $(id -u):$(id -g) -v ${HOME}:/home/az -e HOME=/home/az --rm -it mcr.microsoft.com/azure-cli az'" >> ~/.bashrc
source ~/.bashrc
Now you should be able to use it with standard commands, for example:
az vm extension image list
YMMV and may God have mercy on your soul.
@fengzhou-msft Could you take a look at this issue? sudo apt install azure-cli does not work in Ubuntu 20.04.
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.
A new Focal package is just released for azure-cli 2.6.0
Confirmed. I just installed it and encountered none of the issues that I was before. Closing ticket. Thanks for the heads up!
Most helpful comment
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/)