首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法启动google-cloud-sdk,无法导入名称_remove_dead_weakref

无法启动google-cloud-sdk,无法导入名称_remove_dead_weakref
EN

Stack Overflow用户
提问于 2020-09-09 10:11:32
回答 2查看 608关注 0票数 0

我想登录到gke,我遵循以下指南:https://cloud.google.com/sdk/docs/downloads-versioned-archives

代码语言:javascript
复制
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上。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-09-10 14:59:27

在卸载Python并删除所有与Python相关的环境变量后,它就开始工作了。它在cmd上运行得完美无缺,在PowerShell上只显示了以下内容:

代码语言:javascript
复制
Welcome to the Google Cloud SDK!
Active code page: 65001

直到我按下ctrl+c。

票数 0
EN

Stack Overflow用户

发布于 2020-09-10 13:38:54

我在我的Windows 10机器上重新创建了您的案例:

代码语言:javascript
复制
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上测试了它,一切都如预期的那样工作:

代码语言:javascript
复制
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)?

在你的环境中,有一件事我觉得很奇怪:

代码语言:javascript
复制
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

代码语言:javascript
复制
C:\google-cloud-sdk-308.0.0-windows-x86_64-bundled-python\google-cloud-sdk\platform\bundledpython

对于Python2

代码语言:javascript
复制
C:\google-cloud-sdk-308.0.0-windows-x86_64-bundled-python\google-cloud-sdk\platform\bundledpython2

❗和not:

代码语言:javascript
复制
C:\Users\LF\.kube\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe

因此,首先,我将尝试取消设置CLOUDSDK_PYTHON env:

代码语言:javascript
复制
set CLOUDSDK_PYTHON=

如果这没有帮助,我将查找与Python解释器路径相关的任何其他env var:

代码语言:javascript
复制
set | findstr PYTHON

此外,您甚至可以通过运行以下命令搜索C:\Users\LF\.kube\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe路径设置的确切位置:

代码语言:javascript
复制
set | findstr "C:\Users\LF\.kube\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe"

然后撤销这样的变量。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63809437

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档