【问题标题】:Google cloud sdk not working when python points python3当python指向python3时谷歌云sdk不起作用
【发布时间】:2016-05-24 13:39:52
【问题描述】:

我目前正在尝试在我的 macbook 上安装 google cloud sdk。我正在使用 scikit-learn 和 anaconda 进行机器学习,所以我的笔记本电脑上的 python 指向 python3.5。但是google cloud sdk需要python 2.7才能安装,这就是为什么我面临无法安装的问题。

当我运行 install.sh 文件时发生了错误,我不知道如何处理它:

Adam | ~ $ git/google-cloud-sdk/install.sh
Welcome to the Google Cloud SDK!
Traceback (most recent call last):
  File "/Users/AdamLiu/Git/google-cloud-sdk/lib/third_party/enum/__init__.py", line 364, in __getattr__
    return cls._member_map_[name]
KeyError: '_convert'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/AdamLiu/git/google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
    import bootstrapping
  File "/Users/AdamLiu/Git/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 9, in <module>
    import setup
  File "/Users/AdamLiu/Git/google-cloud-sdk/bin/bootstrapping/setup.py", line 34, in <module>
    from googlecloudsdk.core.util import platforms
  File "/Users/AdamLiu/Git/google-cloud-sdk/lib/googlecloudsdk/core/util/platforms.py", line 18, in <module>
    import platform
  File "/Users/AdamLiu/anaconda/lib/python3.5/platform.py", line 117, in <module>
    import sys, os, re, subprocess
  File "/Users/AdamLiu/anaconda/lib/python3.5/subprocess.py", line 364, in <module>
    import signal
  File "/Users/AdamLiu/anaconda/lib/python3.5/signal.py", line 8, in <module>
    _IntEnum._convert(
  File "/Users/AdamLiu/Git/google-cloud-sdk/lib/third_party/enum/__init__.py", line 366, in __getattr__
    raise AttributeError(name)
AttributeError: _convert

提前非常感谢!

【问题讨论】:

    标签: python linux google-app-engine google-cloud-platform google-cloud-sdk


    【解决方案1】:

    在运行 install.sh 之前,将 CLOUDSDK_PYTHON 环境变量设置为 Python 2.x 可执行文件的位置。

    或者确保你的路径中有 python2,以便which python2 可以找到它。

    【讨论】:

    • 您好,感谢您的回复。但我还是不太明白该怎么做。你可以具体解释一下吗?
    • 我找到了解决这个问题的方法:Not working when python points python3,这是否意味着我需要创建另一个名为 gcloud.workaround 的文件并将代码粘贴到其中并再次执行 gcloud?提前致谢。
    • 你安装了 Python 2.x 吗?如果没有,请安装它。如果它安装为 /usr/bin/python2(或 PATH 上的其他地方的 python2),那么您不需要做任何其他事情,因为 install.sh 脚本(阅读它,它非常简单)会执行“which python2”并将找到它。否则,通过 export CLOUDSDK_PYTHON= 将环境变量 CLOUDSDK_PYTHON 设置为指向 python 2.x 可执行文件。
    • 另外值得注意的是捆绑安装没有设置 CLOUDSDK_PYTHON,所以如果你以后要更改路径,除非你设置了,否则 sdk 会中断。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    • 2020-04-10
    • 2019-04-08
    • 2020-06-28
    • 2017-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多