簡體   English   中英

無法卸載/安裝/使用 gcloud cli

[英]Unable to uninstall / install / use the gcloud cli

我一直很高興在運行 macOS Monterey 版本 12.4 的 macbook 上使用 gcloud cli

我做了一個似乎已經破壞 gcloud cli 的 brew brew upgrade ,它要么是brew upgrade ,要么是我所做的 python 安裝,有關如何縮小范圍的任何信息將不勝感激。

因為我用brew安裝了google-cloud-sdk我可以用brew uninstall google-cloud-sdk卸載它

但是,我仍然無法刪除gcloud二進制文件(?)並且我不斷得到顯示以下堆棧跟蹤

運行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是一個有效路徑,運行它會給我以下 output

/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 -V
Python 3.10.5

我希望能夠清理安裝並將其恢復為正常工作的 state,因為我使用cloud_sql_proxy組件能夠定期連接到 GCP 中的數據庫以用於開發目的。

如果需要更多信息,請告訴我。

任何幫助和見解都會非常有幫助。

提前致謝

我通過將其指向 python 2.7 版本(默認安裝)來修復它。

將此行粘貼到您的終端中:

export CLOUDSDK_PYTHON=/usr/bin/python

參考: https://stackoverflow.com/a/64270348/14332340

通過運行/usr/bin/python -V仔細檢查您是否在該路徑上有 python 2.7 可能會很好。

我希望這有幫助!

回答我自己的問題。

我安裝了 Python 3.9 並解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM