Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for python 3.8 #11239

Closed
chi42 opened this issue Nov 14, 2019 · 18 comments · Fixed by #11322
Closed

support for python 3.8 #11239

chi42 opened this issue Nov 14, 2019 · 18 comments · Fixed by #11322
Assignees
Labels
Core CLI core infrastructure
Milestone

Comments

@chi42
Copy link

chi42 commented Nov 14, 2019

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.

@fengzhou-msft fengzhou-msft added the Core CLI core infrastructure label Nov 15, 2019
@fengzhou-msft fengzhou-msft self-assigned this Nov 15, 2019
@fengzhou-msft
Copy link
Member

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

@fengzhou-msft fengzhou-msft added this to the S161 milestone Nov 15, 2019
@haroldrandom
Copy link
Contributor

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

@secstu
Copy link

secstu commented Nov 18, 2019

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

@morscho
Copy link

morscho commented Nov 18, 2019

Downgrading to Python 3.7.5 solved the issued for me.

@chi42
Copy link
Author

chi42 commented Nov 18, 2019

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"

@gnloch
Copy link

gnloch commented Nov 18, 2019

Here is another issue: #10777 (comment).

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:

distname, version, _ = platform.linux_distribution()

@haroldrandom
Copy link
Contributor

haroldrandom commented Nov 19, 2019

@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

@sanderkoenders
Copy link

sanderkoenders commented Nov 19, 2019

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'

@arthfl
Copy link

arthfl commented Nov 19, 2019

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

@jagenheim
Copy link

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

@r-darwish
Copy link

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.

@fengzhou-msft
Copy link
Member

@r-darwish There's already a PR for it: #11229. But it needs some fix.

haroldrandom added a commit that referenced this issue Nov 20, 2019
)

* Fix #11239 , `platform.linux_distribution()` deprecation problem in Python 3.8
* Add SLES (SUSE Linux Enterprise Server) support
* Fix PEP8 code style error
@haroldrandom
Copy link
Contributor

haroldrandom commented Nov 20, 2019

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

@bbaassssiiee
Copy link

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.

@jiasli
Copy link
Member

jiasli commented May 17, 2021

@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?

@bbaassssiiee
Copy link

bbaassssiiee commented May 17, 2021

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.

@eduolalo
Copy link

eduolalo commented May 21, 2021

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/python@3.8/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/python@3.8/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/python@3.8/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'

@jiasli
Copy link
Member

jiasli commented May 24, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core CLI core infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.