Azure-cli: clean install of CLI on OpenSUSE 15 gives error

Created on 27 Apr 2020  路  14Comments  路  Source: Azure/azure-cli

This is autogenerated. Please review and update as needed.

Describe the bug

Created brand-new OpenSUSE 15.1 VM, Installed CLI as per instructions here:

https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-zypper?view=azure-cli-latest

az login

gives error:
Error loading command module 'aro': No module named 'azure.mgmt.redhatopenshift'
details below:

Command Name
az login

Errors:

APIVersion 2019-06-01 is not available
Traceback (most recent call last):
python3.6/site-packages/knack/cli.py, ln 215, in invoke
    cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 631, in execute
    raise ex
cli/core/commands/__init__.py, ln 695, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
cli/core/commands/__init__.py, ln 688, in _run_job
    six.reraise(*sys.exc_info())
...
azure/cli/core/_profile.py, ln 844, in find_through_interactive_flow
    result = self._find_using_common_tenant(token_entry[_ACCESS_TOKEN], resource)
azure/cli/core/_profile.py, ln 877, in _find_using_common_tenant
    tenants = client.tenants.list()
mgmt/resource/subscriptions/subscription_client.py, ln 122, in tenants
    raise NotImplementedError("APIVersion {} is not available".format(api_version))
NotImplementedError: APIVersion 2019-06-01 is not available

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

CLI should login to my Azure account/subscription

Environment Summary

Linux-4.12.14-lp151.28.7-default-x86_64-with-glibc2.3.4
Python 3.6.5
Installer: RPM

azure-cli 2.4.0

Additional Context


Packaging PackaginRPM Workaround

Most helpful comment

I can repro this issue on openSUSE Leap 15.1. We actually saw this issue before in #12783, #12878, #12779 and mistook it for some pip installation problem.

This is the pre-installed Azure CLI on openSUSE Leap 15.1:

> az -v
azure-cli (2.0.45)

acr (2.1.4)
acs (2.3.2)
...
Python location '/usr/bin/python3'
Extensions directory '/home/jladmin/.azure/cliextensions'

Python (Linux) 3.6.5 (default, Mar 31 2018, 19:45:04) [GCC]

Legal docs and information: aka.ms/AzureCliLegal

We have two options here:

1. Contact openSUSE to remove the pre-installed Azure CLI

Since openSUSE Leap 15.1 is not maintained by Microsoft, we need to contact openSUSE to remove the pre-installed Azure CLI to avoid all kinds of problems. Moreover, it can probably cause other problems once we move to PEP 420 (#13293).

image

2. Ship Azure CLI with its own Python

After installing Azure CLI with zypper, we can run

jladmin@jlsuse:~> az -v
azure-cli                          2.6.0

acr                                2.1.4
acs                                2.3.2
...

Python location '/usr/bin/python3'

We can see Azure CLI is using the system /usr/bin/python3 on openSUSE, it may conflicts with the pre-installed packages. We can ship Azure CLI with its own Python like how we do on Ubuntu with a deb package.

All 14 comments

@fengzhou-msft please take a look

I just created a SLES 15 SP1 PAYG VM. I ran into same error.

My customer is using a Centos redhat base and they are getting the same error.

Seeing this as well.

+1 on Ubuntu

It seems OpenSUSE 15.1 VM comes with a very old version of azure cli (2.0.45). It has a bunch of old azure-cli-* module packages and old dependencies installed in the system python site-packages directory(/usr/lib/python3.6/site-packages). With newer versions of azure-cli, all the modules are consolidated into one azure-cli package and all dependecies are installed under /usr/lib64/az/lib/python3.6/site-packages to not share the dependencies on purpose. The old dependencies was loaded and caused issues.

If you haven't installed other python packages, the easiest way to clean up these old azure-cli packages and dependencies is to sudo zypper remove python3 and sudo rm -rf /usr/lib/python3.6/site-packages. Then you can run sudo zypper install --from azure-cli azure-cli to install the latest azure-cli and its dependencies including python3.

I can repro this issue on openSUSE Leap 15.1. We actually saw this issue before in #12783, #12878, #12779 and mistook it for some pip installation problem.

This is the pre-installed Azure CLI on openSUSE Leap 15.1:

> az -v
azure-cli (2.0.45)

acr (2.1.4)
acs (2.3.2)
...
Python location '/usr/bin/python3'
Extensions directory '/home/jladmin/.azure/cliextensions'

Python (Linux) 3.6.5 (default, Mar 31 2018, 19:45:04) [GCC]

Legal docs and information: aka.ms/AzureCliLegal

We have two options here:

1. Contact openSUSE to remove the pre-installed Azure CLI

Since openSUSE Leap 15.1 is not maintained by Microsoft, we need to contact openSUSE to remove the pre-installed Azure CLI to avoid all kinds of problems. Moreover, it can probably cause other problems once we move to PEP 420 (#13293).

image

2. Ship Azure CLI with its own Python

After installing Azure CLI with zypper, we can run

jladmin@jlsuse:~> az -v
azure-cli                          2.6.0

acr                                2.1.4
acs                                2.3.2
...

Python location '/usr/bin/python3'

We can see Azure CLI is using the system /usr/bin/python3 on openSUSE, it may conflicts with the pre-installed packages. We can ship Azure CLI with its own Python like how we do on Ubuntu with a deb package.

+1 on Ubuntu

@magaal, the Azure CLI package on Ubuntu has a built-in Python, which shouldn't suffer from this issue. After installing Azure CLI with apt:

$ az -v
azure-cli                          2.6.0

Python location '/opt/az/bin/python3'

You can see the Python Azure CLI uses is /opt/az/bin/python3.

To help us analysis this issue, could you share

  1. The image and version of your Ubuntu
  2. How you installed Azure CLI

The reason why directly running sudo zypper install --from azure-cli azure-cli doesn't work is because the empty /usr/lib/python3.6/site-packages/azure/__init__.py makes Python treat azure as a regular package, and thus stop using /usr/lib64/az/lib/python3.6/site-packages/azure which is assigned in the az script:

> which az
/usr/bin/az

> cat /usr/bin/az
#!/usr/bin/env bash
AZ_INSTALLER=RPM PYTHONPATH=/usr/lib64/az/lib/python3.6/site-packages /usr/bin/python3 -sm azure.cli "$@"

https://www.python.org/dev/peps/pep-0420/#specification

If <directory>/foo/__init__.py is found, a regular package is imported and returned.

It seems OpenSUSE 15.1 VM comes with a very old version of azure cli (2.0.45). It has a bunch of old azure-cli-* module packages and old dependencies installed in the system python site-packages directory(/usr/lib/python3.6/site-packages). With newer versions of azure-cli, all the modules are consolidated into one azure-cli package and all dependecies are installed under /usr/lib64/az/lib/python3.6/site-packages to not share the dependencies on purpose. The old dependencies was loaded and caused issues.

If you haven't installed other python packages, the easiest way to clean up these old azure-cli packages and dependencies is to sudo zypper remove python3 and sudo rm -rf /usr/lib/python3.6/site-packages. Then you can run sudo zypper install --from azure-cli azure-cli to install the latest azure-cli and its dependencies including python3.

If you have other Python applications installed, you can use the follwoing workaround:
First, install back the old azure-cli that comes with the VM image:
sudo zypper install --oldpackage azure-cli-2.0.45-4.22.noarch
This way zypper knows what packages the old azure-cli depends on, then remove the old azure-cli and its dependencies:
sudo zypper rm -y --clean-deps azure-cli
Finally, follow the doc to install the latest azure-cli:
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-zypper?view=azure-cli-latest

We're also reaching out to the team that builds the image to either upgrade or remove the old azure-cli.

@fengzhou-msft Thanks for the information
OS: openSUSE Leap 15.2

The old package in Main repo name should use azure-cli-2.0.45-lp152.2.2
# zypper install -y --oldpackage azure-cli-2.0.45-lp152.2.2

but if openSUSE user use pip3 to install ansible with Azure ( https://docs.ansible.com/ansible/latest/scenario_guides/guide_azure.html)
# pip3 install ansible[azure]

after we clean dependencies and install new azure-cli, ansible command doesn't work anymore :p

I'm experiencing this issue on openSUSE Tumbleweed when I try to login with 'az login':

Error loading command module 'aro': No module named 'azure.mgmt.redhatopenshift'

@DataRepository are you able to run az --version to check your version? Does the instruction work for you?

@fengzhou-msft
OS: openSUSE Leap 15.2

After ansible 2.10, azure module move to external collections
ansible azure module use " #ansible-galaxy collection install azure.azcollection "

I try to install azure-cli first (clean openSUSE Leap 15.2, not install any python package)

when I run

az --version

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

like https://github.com/Azure/azure-cli/issues/8716

Was this page helpful?
0 / 5 - 0 ratings