Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

python - gcloud not working after updating manjaro

I had some system updates for my manjaro installation and after that I get the following error message when trying to run gcloud:

gcloud components update
Traceback (most recent call last):
  File "/home/mani/Downloads/google-cloud-sdk/lib/gcloud.py", line 104, in <module>
    main()
  File "/home/mani/Downloads/google-cloud-sdk/lib/gcloud.py", line 62, in main
    from googlecloudsdk.core.util import encoding
  File "/home/mani/Downloads/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
    from googlecloudsdk.core.util import importing
  File "/home/mani/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
    import imp
  File "/usr/lib/python3.9/imp.py", line 23, in <module>
    from importlib import util
  File "/usr/lib/python3.9/importlib/util.py", line 2, in <module>
    from . import abc
  File "/usr/lib/python3.9/importlib/abc.py", line 17, in <module>
    from typing import Protocol, runtime_checkable
  File "/usr/lib/python3.9/typing.py", line 26, in <module>
    import re as stdlib_re  # Avoid confusion with the re we export.
  File "/usr/lib/python3.9/re.py", line 124, in <module>
    import enum
  File "/home/mani/Downloads/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module>
    spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'

After looking online I found that the problem could be that this version of gcloud doesn't support python3.9 and the recommended solution was to run gcloud components update but that gives the same error. Is there a way I could revert or make the command use an older python version to upgrade itself then go back to the new python 3.9?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As per following GCP official document you can restore your Cloud Shell VM to it's original state by removing the home directory as follows:

ls -a $HOME

sudo rm -rf $HOME

Now in the Cloud Shell click on the three dot menu and restart the VM will create an new VM and home directory will be restore as it's default state.

As you have the issue in your local machine, after researching I have noticed following PIT1 as a bug in Google Issue Tracker. There are few WA for now on the following thread you can apply it accordingly.

There is another PIT2 as a Feature request to add support for python 3.9. Feel free to post there should you have any additional comments or concerns regarding the issue.

Another WA found in the github might be useful for your use case.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...