Is your feature request related to a problem? Please describe.
Unable to install Azure CLI on Arch Linux due to the CLI not supporting python 3.8. Some APIs that the CLI relies on were deprecated and removed in python 3.8.
Examples of deprecated APIs that I'm hitting:
Traceback (most recent call last):
File "/usr/lib64/python3.8/runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib64/python3.8/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/chi/lib/azure-cli/lib/python3.8/site-packages/azure/cli/__main__.py", line 33, in <module>
az_cli = get_default_cli()
File "/home/chi/lib/azure-cli/lib/python3.8/site-packages/azure/cli/core/__init__.py", line 546, in get_default_cli
return AzCli(cli_name='az',
File "/home/chi/lib/azure-cli/lib/python3.8/site-packages/azure/cli/core/__init__.py", line 55, in __init__
SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600)
File "/home/chi/lib/azure-cli/lib/python3.8/site-packages/azure/cli/core/_session.py", line 46, in load
if st.st_mtime + max_age < time.clock():
AttributeError: module 'time' has no attribute 'clock'
and:
AttributeError: module 'platform' has no attribute 'linux_distribution'
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Thanks for submitting the issue. We'll take a look.
Which casuing this error AttributeError: module 'platform' has no attribute 'linux_distribution'?
I'm experiencing the same issue on the latest build of Windows 10 Version 10.0.18362 Build 18362 running the newest 64bit version of Python.
Error:
Message=module 'time' has no attribute 'clock'
Source=C:\Users\xxxxxxxxxx\Documents\Repos\Selenium\xxxxxxxxxx\scripts\main.py
StackTrace:
File "C:\Users\xxxxxxxxxx\Documents\Repos\Selenium\Axxxxxxxxxx\scripts\main.py", line 15, in az_cli
cli = get_default_cli()
File "C:\Users\xxxxxxxxxx\Documents\Repos\Selenium\xxxxxxxxxx\scripts\main.py", line 26, in az_cmds
operation = encryptionTest.az_cli(resource)
File "C:\Users\xxxxxxxxxx\Documents\Repos\Selenium\xxxxxxxxxx\scripts\main.py", line 30, in <module>
xxxxxxxxxx.az_cmds()
Code that triggers the error:
def az_cli(args_str):
args = args_str.split()
cli = get_default_cli()
cli.invoke(args)
if cli.result.result:
return cli.result.result
elif cli.result.error:
raise cli.result.error
return True
Downgrading to Python 3.7.5 solved the issued for me.
Which casuing this error
AttributeError: module 'platform' has no attribute 'linux_distribution'?
From running the bash install script "curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash"
Here is another issue: https://github.com/Azure/azure-cli/pull/10777#issuecomment-554328827.
with python 3.8 i've this error on azure-cli install:
AttributeError: module 'platform' has no attribute 'linux_distribution'
info:
Python version 3.8.0
OS: archlinux updated on 15/11/2019
It seems to be caused by platform.linux_platform being removed of python 3.8.
A quick search reveled the use of this function here: https://github.com/Azure/azure-cli/blob/baae1d17ffc4f3abfeccea17116bfd61de5770f1/scripts/curl_install_pypi/install.py#L309
@gnloch Thanks!
@chi42 For the first question AttributeError: module 'time' has no attribute 'clock' , has be fixed alreay. Please upgrade azure-cli to latest release.
For the second issue. We are fixing it
I am also having trouble with the new python 3.8. Downgraded to python 3.7 for now. Let's hope this is fixed soon. I just want to add that the installation described in the Azure CLI installation docs doesn't work either because of the error mentioned previously.
AttributeError: module 'platform' has no attribute 'linux_distribution'
As a workaround, i created a little shell script at $HOME/bin/az with the following content:
#!/usr/bin/env bash
set -eu
command="$@"
docker run --rm --volume $HOME/.azure:/root/.azure mcr.microsoft.com/azure-cli az $command
This assumes that there's $HOME/.azure directory.
That way you don't have to mangle your python installation and can still use the az CLI
Which casuing this error
AttributeError: module 'platform' has no attribute 'linux_distribution'?From running the bash install script "curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash"
The 'platform.linux_distribution' is used extensively throughout most scripts.
When using InstallAzureCLI (without the Deb extension) the error comes from verify_native_dependencies() in the install.py script which is downloaded by InstallAzureCLI.
Short-circuiting this function by placing a return there only postpones the issue until later (virtualenv calling download.py).
StackOverflow seem to suggest the distro project, which seems maintained. @fengzhou-msft - is it okay to add this package as a dependency? If so, I may find some time to work on this.
@r-darwish There's already a PR for it: https://github.com/Azure/azure-cli/pull/11229. But it needs some fix.
Hey, guys. The bug should be fixed now.
Please have a try against latest dev branch or can wait until 2.0.77 release.