简体   繁体   中英

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

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.

Since I installed the google-cloud-sdk with brew I could uninstall it with brew uninstall google-cloud-sdk

However, I'm still unable to remove the gcloud binary(?) and I constantly get show the following stack trace

Running gcloud -h produces the following error (please note this after I uninstalled the 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 -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.

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).

Paste this line in your terminal:

export CLOUDSDK_PYTHON=/usr/bin/python

Ref: 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 .

I hope this helps!

Answering my own question.

I installed Python 3.9 and that fixed the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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