azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

support for python 3.8

Open chi42 opened this issue 7 years ago • 18 comments

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:

 az                  
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.

chi42 avatar Nov 14 '19 21:11 chi42

Thanks for submitting the issue. We'll take a look.

fengzhou-msft avatar Nov 15 '19 02:11 fengzhou-msft

Which casuing this error AttributeError: module 'platform' has no attribute 'linux_distribution' ?

haroldrandom avatar Nov 18 '19 10:11 haroldrandom

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

0xkam avatar Nov 18 '19 13:11 0xkam

Downgrading to Python 3.7.5 solved the issued for me.

morscho avatar Nov 18 '19 13:11 morscho

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"

chi42 avatar Nov 18 '19 14:11 chi42

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 avatar Nov 18 '19 19:11 gnloch

@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

haroldrandom avatar Nov 19 '19 07:11 haroldrandom

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'

sanderkoenders avatar Nov 19 '19 09:11 sanderkoenders

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

arthfl avatar Nov 19 '19 09:11 arthfl

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).

jagenheim avatar Nov 19 '19 13:11 jagenheim

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 avatar Nov 19 '19 21:11 r-darwish

@r-darwish There's already a PR for it: https://github.com/Azure/azure-cli/pull/11229. But it needs some fix.

fengzhou-msft avatar Nov 20 '19 02:11 fengzhou-msft

Hey, guys. The bug should be fixed now. Please have a try against latest dev branch or can wait until 2.0.77 release.

haroldrandom avatar Nov 20 '19 07:11 haroldrandom

ansible[azure] 2.9.20 depends on azure-cli-core==2.0.35; extra == "azure"

Too many moving parts lately, ansible 2.9 is finally stable.

bbaassssiiee avatar May 14 '21 20:05 bbaassssiiee

@bbaassssiiee, are you seeing any issue with Azure CLI? If it is related to ansible, could you open an issue at https://github.com/ansible/ansible/issues?

jiasli avatar May 17 '21 01:05 jiasli

There will be no bugfixes on Ansible 2.9, only security-fixes. Workaround is to use python37 for Azure. Ansible 2.9 is embedded in current Ansible Tower release.

bbaassssiiee avatar May 17 '21 06:05 bbaassssiiee

I'm having same issue, I can not downgrade to python3.7 because it does not support apple silicon, this is the error I'm having when I'm trying to get te logs form some resource:

Command: az webapp log tail --ids /my/azure/resource/id

Message it throws: Exception in thread Thread-1: Traceback (most recent call last): File "/opt/homebrew/Cellar/[email protected]/3.8.10/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/opt/homebrew/Cellar/[email protected]/3.8.10/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/opt/homebrew/Cellar/azure-cli/2.23.0/libexec/lib/python3.8/site-packages/azure/cli/command_modules/appservice/custom.py", line 2343, in _get_log logger.warning(chunk.decode(encoding='utf-8', errors='replace') File "/opt/homebrew/Cellar/[email protected]/3.8.10/Frameworks/Python.framework/Versions/3.8/lib/python3.8/logging/__init__.py", line 1458, in warning self._log(WARNING, msg, args, **kwargs) TypeError: _log() got an unexpected keyword argument 'end'

eduolalo avatar May 21 '21 16:05 eduolalo

@kalmecak, what you are seeing belongs to another issue #17987 which has been fixed by #17988.

jiasli avatar May 24 '21 01:05 jiasli