简体   繁体   English

安装 Google Cloud SDK 时出错

[英]Error Installation Google Cloud SDK

While following the installation steps for "Mac OS X" Installation and Quick Start按照“Mac OS X”安装和快速入门的安装步骤进行操作

I used the below command:-我使用了以下命令:-

curl https://sdk.cloud.google.com | bash

and directory extract under /Users/xxxxx/google-cloud-sdk//Users/xxxxx/google-cloud-sdk/下的目录提取

but I got this error:-但我收到了这个错误:-

Traceback (most recent call last):
File "/Users/xxxxx/google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
import bootstrapping
File "/Users/xxxxx/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 9, in <module>
import setup
File "/Users/xxxxx/google-cloud-sdk/bin/bootstrapping/setup.py", line 44, in <module>
from googlecloudsdk.core.util import platforms
File "/Users/xxxxx/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/core/util/platforms.py", line 6, in <module>
import platform
ImportError: No module named platform

Environment:-环境:-

  • Mac OS X Yosemite 10.10 Mac OS X 优胜美地 10.10
  • Python 2.7.6蟒蛇 2.7.6
  • $ whereis python /usr/bin/python $ whereis python /usr/bin/python

Can someone help?有人可以帮忙吗?

I have found different locations of standard modules, for example:-我发现了标准模块的不同位置,例如:-

  • >>> import platform >>> platform.__file__ => '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/platform‌​.pyc' >>> import platform >>> platform.__file__ => '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/platform‌​.pyc'
  • >>> import os >>> os.__file__ => somewhere inside my profile /Users/xxxxx/Library/Frameworks/Python.framework/... , >>> import os >>> os.__file__ => 在我的个人资料/Users/xxxxx/Library/Frameworks/Python.framework/...某处,

So, I have solved this issue by following steps:-所以,我通过以下步骤解决了这个问题:-

  • removed /Users/xxxxx/Library/Frameworks/Python.framework/ .删除/Users/xxxxx/Library/Frameworks/Python.framework/
  • reinstalled python through brew to keep Apple python away.通过brew重新安装 python 以防止 Apple python 出现。

then, Google Cloud SDK was installed smoothly and is working properly.然后,Google Cloud SDK 顺利安装并正常工作。

and the new location of standard modules is /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/标准模块的新位置是/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/

I can't comment since i don't have enough rep, so posting as an "answer".我无法发表评论,因为我没有足够的代表,所以发布为“答案”。

As others have commented, platform is a standard module.正如其他人评论的那样,平台是一个标准模块。 It should be there barring a bad python installation.除非python安装不好,否则它应该在那里。 Since the python in PATH seems to import platform correctly, maybe Cloud SDK is using a different python.由于 PATH 中的 python 似乎正确导入了平台,因此 Cloud SDK 可能使用了不同的 python。

Check if the environment variable CLOUDSDK_PYTHON is set.检查是否设置了环境变量 CLOUDSDK_PYTHON。 That usually tells gcloud to use a different python.这通常会告诉 gcloud 使用不同的 python。

You can also change /Users/xxxxx/google-cloud-sdk/bin/gcloud and right before the last line, echo the bash variables $CLOUDSDK_PYTHON, $CLOUDSDK_PYTHON_ARGS, $CLOUDSDK_ROOT_DIR, and $PYTHONPATH.您还可以更改/Users/xxxxx/google-cloud-sdk/bin/gcloud并在最后一行之前回显 bash 变量 $CLOUDSDK_PYTHON、$CLOUDSDK_PYTHON_ARGS、$CLOUDSDK_ROOT_DIR 和 $PYTHONPATH。 This should tell us if something is configured badly with the python that gcloud uses.这应该告诉我们 gcloud 使用的 python 是否配置错误。

on linux i fixed this by running install.py directly .you can apply the same on mac os i guess, go to the folder where you have extracted google cloud sdk then,在 linux 上,我通过直接运行 install.py 解决了这个问题。我猜你可以在 mac os 上应用相同的方法,然后转到你解压谷歌云 sdk 的文件夹,

 cd /bin/bootstrapping

there you will find install.py ,run it using在那里你会找到 install.py ,运行它

./install.py

then installation begins and proceed with the steps .After that open a new terminal gcloud works!然后安装开始并继续执行步骤。之后打开一个新的终端 gcloud 工作!

与不同的系统包(contextlib)有类似的问题,通过在安装前设置环境参数:CLOUDSDK_PYTHON_SITEPACKAGES=1 解决了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM