我想登录到gke,我遵循以下指南:https://cloud.google.com/sdk/docs/downloads-versioned-archives
C:\google-cloud-sdk-308.0.0-windows-x86_64-bundled-python>"./google-cloud-sdk/bin/gcloud" init
ERROR: gcloud failed to load: cannot import name _remove_dead_weakref
gcloud_main = _import_gcloud_main()
import googlecloudsdk.gcloud_main
from googlecloudsdk.api_lib.iamcredentials import util as iamcred_util
from googlecloudsdk.api_lib.util import apis_internal
from googlecloudsdk.core import properties
from googlecloudsdk.core import config
from googlecloudsdk.core.util import files as file_utils
import logging
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
from _weakref import (
This usually indicates corruption in your gcloud installation or problems with your Python interpreter.
Please verify that the following is the path to a working Python 2.7 or 3.5+ executable:
C:\Users\LF\.kube\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe
If it is not, please set the CLOUDSDK_PYTHON environment variable to point to a working Python 2.7 or 3.5+ executable.
If you are still experiencing problems, please reinstall the Cloud SDK using the instructions here:
https://cloud.google.com/sdk/使用CLOUDSDK_PYTHON设置set没有帮助。我在Windows 10 64位和Python2.7.15上。
发布于 2020-09-10 14:59:27
在卸载Python并删除所有与Python相关的环境变量后,它就开始工作了。它在cmd上运行得完美无缺,在PowerShell上只显示了以下内容:
Welcome to the Google Cloud SDK!
Active code page: 65001直到我按下ctrl+c。
发布于 2020-09-10 13:38:54
我在我的Windows 10机器上重新创建了您的案例:
C:\google-cloud-sdk-308.0.0-windows-x86_64-bundled-python> cmd /c ver
Microsoft Windows [Version 10.0.17763.973]但无法重现你遇到的错误。我在当前版本的64-bundled-python.zip上以及在旧版本的64-bundled-python.zip上测试了它,一切都如预期的那样工作:
C:\google-cloud-sdk-308.0.0-windows-x86_64-bundled-python>".\google-cloud-sdk\bin\gcloud" --version
Google Cloud SDK 308.0.0
bq 2.0.60
core 2020.08.28
gsutil 4.53
C:\google-cloud-sdk-308.0.0-windows-x86_64-bundled-python>".\google-cloud-sdk\bin\gcloud" init
Welcome! This command will take you through the configuration of gcloud.
Your current configuration has been set to: [default]
You can skip diagnostics next time by using the following flag:
gcloud init --skip-diagnostics
Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).
You must log in to continue. Would you like to log in (Y/n)?在你的环境中,有一件事我觉得很奇怪:
Please verify that the following is the path to a working Python 2.7 or 3.5+ executable:
C:\Users\LF\.kube\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe如我所见,您可以从./google-cloud-sdk/bin/gcloud" init目录运行您的C:\google-cloud-sdk-308.0.0-windows-x86_64-bundled-python命令。
由于这个压缩存档已经包含捆绑的Python解释器(包括2.7和3.7版本),因此您不需要为云sdk额外设置到它的路径。
因此,它试图搜索python解释器的位置看起来有点奇怪,因为它应该使用这两条路径中的一条:
对于Python3
C:\google-cloud-sdk-308.0.0-windows-x86_64-bundled-python\google-cloud-sdk\platform\bundledpython对于Python2
C:\google-cloud-sdk-308.0.0-windows-x86_64-bundled-python\google-cloud-sdk\platform\bundledpython2❗和not:
C:\Users\LF\.kube\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe因此,首先,我将尝试取消设置CLOUDSDK_PYTHON env:
set CLOUDSDK_PYTHON=如果这没有帮助,我将查找与Python解释器路径相关的任何其他env var:
set | findstr PYTHON此外,您甚至可以通过运行以下命令搜索C:\Users\LF\.kube\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe路径设置的确切位置:
set | findstr "C:\Users\LF\.kube\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe"然后撤销这样的变量。
https://stackoverflow.com/questions/63809437
复制相似问题