What happened:
I get an error when running for instance kubectl get nodes:
Unable to connect to the server: error executing access token command "/usr/lib64/google-cloud-sdk/bin/gcloud config config-helper --format=json": err=exit status 1 output= stderr=Traceback (most recent call last):
File "/usr/lib64/google-cloud-sdk/lib/gcloud.py", line 104, in
main()
File "/usr/lib64/google-cloud-sdk/lib/gcloud.py", line 62, in main
from googlecloudsdk.core.util import encoding
File "/usr/lib64/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in
from googlecloudsdk.core.util import importing
File "/usr/lib64/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in
import imp
File "/usr/lib64/python3.9/imp.py", line 23, in
from importlib import util
File "/usr/lib64/python3.9/importlib/util.py", line 2, in
from . import abc
File "/usr/lib64/python3.9/importlib/abc.py", line 17, in
from typing import Protocol, runtime_checkable
File "/usr/lib64/python3.9/typing.py", line 26, in
import re as stdlib_re # Avoid confusion with the re we export.
File "/usr/lib64/python3.9/re.py", line 124, in
import enum
File "/usr/lib64/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in
spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'
What you expected to happen:
I expect a list of resource information.
How to reproduce it (as minimally and precisely as possible):
Run kubectl get nodes on a Fedora 33 desktop installation.
Anything else we need to know?:
Environment:
kubectl version): Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3", GitCommit:"1e11e4a2108024935ecfcb2912226cedeafd99df", GitTreeState:"clean", BuildDate:"2020-10-14T12:50:19Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}
cat /etc/os-release): Fedora 33@lpellegr: This issue is currently awaiting triage.
SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.
The triage/accepted label can be added by org members by writing /triage accepted in a comment.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
This makes me think it is a problem with your gcloud client
/usr/lib64/google-cloud-sdk/bin/gcloud config config-helper --format=json
That call stack is definitely not originating from inside kubernetes.
Oops, indeed, the problem is with the _gcloud_ client that seems not compatible with Python 3.9:
https://stackoverflow.com/questions/64010263/gcloud-not-working-with-fedora33-and-python3-9
I am sorry for the noise.
Also happened for me on MacOS/Homebrew after a recent brew upgrade
Suggested fix: export CLOUDSDK_PYTHON=python2
Also happened after a brew upgrade for me (ugh). I can confirm that export CLOUDSDK_PYTHON=python2 works though.
Happened to me after a brew upgrade. Works with python 3.8 . I had to add:
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
alias python=/usr/local/opt/[email protected]/bin/python3
to .zshrc.
This works because I have the [email protected] homebrew package installed. I use zsh.
I filed a bug upstream: https://issuetracker.google.com/issues/172647331
For usage with python3 i also had to update the gcloud sdk.
brew install [email protected]
export CLOUDSDK_PYTHON=python3
gcloud components update
@asulaiman I followed the steps that you mentioned but got this error
โฏ gcloud components update
/Users/my-user-name/google-cloud-sdk/bin/gcloud: line 162: exec: python3.8: not found
Updated comment, try export CLOUDSDK_PYTHON=python3 instead.
I have this in my zshrc file
export CLOUDSDK_PYTHON=python3.8
Still getting the error. I think gcloud is able to pick up this variable. its unable to pick up python3.8 from mac.
This worked for me on macos export CLOUDSDK_PYTHON=python3
this problem was fixed in the upstream. Just upgrade to 318.0.0 version: gcloud components update
The only way worked for me - switch temporary back to python2
export CLOUDSDK_PYTHON=python2
gcloud components update
export CLOUDSDK_PYTHON=python3
Most helpful comment
Also happened for me on MacOS/Homebrew after a recent
brew upgradeSuggested fix:
export CLOUDSDK_PYTHON=python2