[英]Unable to uninstall / install / use the gcloud cli
I had been happily using the gcloud cli on my macbook running on macOS Monterey version 12.4我一直很高兴在运行 macOS Monterey 版本 12.4 的 macbook 上使用 gcloud cli
I did a brew upgrade
which seems to have broken the gcloud cli, its either the brew upgrade
or a python install which I did, any info on how to narrow this down would be appreciated.我做了一个似乎已经破坏 gcloud cli 的 brew
brew upgrade
,它要么是brew upgrade
,要么是我所做的 python 安装,有关如何缩小范围的任何信息将不胜感激。
Since I installed the google-cloud-sdk
with brew
I could uninstall it with brew uninstall google-cloud-sdk
因为我用
brew
安装了google-cloud-sdk
我可以用brew uninstall google-cloud-sdk
卸载它
However, I'm still unable to remove the gcloud
binary(?) and I constantly get show the following stack trace但是,我仍然无法删除
gcloud
二进制文件(?)并且我不断得到显示以下堆栈跟踪
Running gcloud -h
produces the following error (please note this after I uninstalled the google-cloud-sdk
)运行
gcloud -h
会产生以下错误(请在我卸载google-cloud-sdk
后注意这一点)
ERROR: gcloud failed to load: module 'collections' has no attribute 'Mapping'
gcloud_main = _import_gcloud_main()
import googlecloudsdk.gcloud_main
from googlecloudsdk.calliope import cli
from googlecloudsdk.calliope import actions
from googlecloudsdk.calliope import markdown
from googlecloudsdk.calliope import usage_text
from googlecloudsdk.calliope import parser_arguments
from googlecloudsdk.calliope import parser_completer
from googlecloudsdk.core.console import progress_tracker
class _BaseStagedProgressTracker(collections.Mapping):
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:
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
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/
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
is a valid path and running it gives me the following output /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
是一个有效路径,运行它会给我以下 output
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 -V
Python 3.10.5
I would like to be able to clean up the installation and get it back to a working state as I use the cloud_sql_proxy
component to be able to connect to databases in GCP regularly for development purposes.我希望能够清理安装并将其恢复为正常工作的 state,因为我使用
cloud_sql_proxy
组件能够定期连接到 GCP 中的数据库以用于开发目的。
Please let me know if further information is needed.如果需要更多信息,请告诉我。
Any help and insights would be very helpful.任何帮助和见解都会非常有帮助。
Thanks in advance提前致谢
I fixed it by pointing it to python 2.7 version (installed by default).我通过将其指向 python 2.7 版本(默认安装)来修复它。
Paste this line in your terminal:将此行粘贴到您的终端中:
export CLOUDSDK_PYTHON=/usr/bin/python
Ref: https://stackoverflow.com/a/64270348/14332340参考: https://stackoverflow.com/a/64270348/14332340
Might be good to double check if you have python 2.7 at that path, by running /usr/bin/python -V
.通过运行
/usr/bin/python -V
仔细检查您是否在该路径上有 python 2.7 可能会很好。
I hope this helps!我希望这有帮助!
Answering my own question.回答我自己的问题。
I installed Python 3.9 and that fixed the issue.我安装了 Python 3.9 并解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.