Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Gcloud command fails after gcloud components update

 

I have trouble running gcloud commands after gcloud components update.

I'm using VS code Ubuntu 20.04. The error I get is:

ile "/home/user/google-cloud-sdk/lib/googlecloudsdk/core/util/encoding.py", line 41, in Encode
    if not six.PY2:
AttributeError: module 'six' has no attribute 'PY2'

I have installed six module.

I've installed six with:

pip install six

I've set CLOUDSDK_PYTHON=/home/user/.pyenv/versions/3.10.0/bin/python3.10.

When executing Python3.10, and import six and print(six.PY2) everything works fine, and I don't get error. Only when executing gcloud commands.

What could be the reason for this?

The output of pip show six:

Name: six
Version: 1.16.0
Summary: Python 2 and 3 compatibility utilities
Home-page: https://github.com/benjaminp/six
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /home/user/.pyenv/versions/3.10.0/lib/python3.10/site-packages
1 1 1,796
1 REPLY 1

Hi @zoom_bat,

Welcome to Google Cloud Community!

You may want to perform the following in order to check whether gcloud SDK is properly installed:

  • Type gcloud version to check the current version installed in your system. Latest version is 466.0.0.
  • Check the Python version installed. The Google Cloud CLI requires Python 3.8 to 3.12.
  • Please check this documentation on installing gcloud CLI 
  • You may also reinstall gcloud CLI by following this documentation on uninstalling gcloud CLI then installing gcloud CLI again.

If the aforementioned steps didn't work, you may file a bug so that our engineers could take a look at this. We don't have a specific ETA but you can keep track of its progress once the ticket has been created.

Hope this helps.