Skip to content

Failure on SLES 15 SP3 VM: No module named azure.cli.__main__ #20839

Description

@jiasli

Describe the bug

Following https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=zypper, a freshly installed Azure CLI fails with

> az -v
/usr/bin/python3.6: No module named azure.cli.__main__; 'azure.cli' is a package and cannot be directly executed

This is because SLES (SUSE Linux Enterprise Server) 15 SP3 VM has a pre-installed Azure CLI 2.16.0 which is outdated and conflicts with latest version.

> ls -d /usr/lib/python3.6/site-packages/azure_cli*
/usr/lib/python3.6/site-packages/azure_cli-2.16.0-py3.6.egg-info
/usr/lib/python3.6/site-packages/azure_cli_command_modules_nspkg-2.0.3-py3.6.egg-info
/usr/lib/python3.6/site-packages/azure_cli_core-2.16.0-py3.6.egg-info
/usr/lib/python3.6/site-packages/azure_cli_nspkg-3.0.4-py3.6.egg-info
/usr/lib/python3.6/site-packages/azure_cli_telemetry-1.0.6-py3.6.egg-info

> ls -l /usr/lib/python3.6/site-packages/azure/cli
total 16
-rw-r--r--  1 root root    0 Jun 28  2019 __init__.py
-rw-r--r--  1 root root 5532 Dec  4  2020 __main__.py
drwxr-xr-x  2 root root   37 Dec 16 11:27 __pycache__
drwxr-xr-x 65 root root 4096 Dec 16 11:28 command_modules
drwxr-xr-x  8 root root 4096 Dec 16 11:28 core
drwxr-xr-x  4 root root   93 Dec 16 11:27 telemetry

After installing the latest version, /usr/lib/python3.6/site-packages/azure/cli/__main__.py is removed

> ls -l /usr/lib/python3.6/site-packages/azure/cli
total 4
-rw-r--r-- 1 root root    0 Jun 28  2019 __init__.py
drwxr-xr-x 2 root root   37 Dec 16 11:27 __pycache__
drwxr-xr-x 3 root root   44 Dec 27 08:58 command_modules
drwxr-xr-x 8 root root 4096 Dec 16 11:28 core
drwxr-xr-x 4 root root   93 Dec 16 11:27 telemetry

leaving /usr/lib/python3.6/site-packages/azure/cli a regular package, conflicting with the latest Azure CLI which is a namespace package under /usr/lib64/az/lib/python3.6/site-packages/azure/cli (#14372).

Solution

Remove the pre-installed Azure CLI before installing the latest one:

> sudo zypper rm -y --clean-deps azure-cli

If you have already installed the latest one, revert back to the pre-installed one first and reinstall the latest one:

> sudo zypper install --oldpackage azure-cli-2.16.0-6.7.1
> sudo zypper rm -y --clean-deps azure-cli

The package name may vary on different system version, run zypper --no-refresh info azure-cli on a new SLES 15 SP3 VM to check the source package format:

> zypper --no-refresh info azure-cli

Information for package azure-cli:
----------------------------------
Repository     : @System
Name           : azure-cli
Version        : 2.16.0-6.7.1
Arch           : noarch
Vendor         : SUSE LLC <https://www.suse.com/>
Support Level  : unknown
Installed Size : 15.9 MiB
Installed      : Yes
Status         : up-to-date
Source package : azure-cli-2.16.0-6.7.1.src
Summary        : Microsoft Azure CLI 2.0
Description    :
    Microsoft Azure CLI 2.0 Command Line Utilities

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions