Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gsutil no longer works?

I've been using gcloud and gsutil for a while but now suddenly for any gsutil command I run I get errors:

Traceback (most recent call last):
  File "/Users/julian/google-cloud-sdk/bin/bootstrapping/gsutil.py", line 12, in 
    import bootstrapping
  File "/Users/julian/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 22, in 
    from googlecloudsdk.core.credentials import store as c_store
  File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/credentials/store.py", line 27, in 
    from googlecloudsdk.core import http
  File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/http.py", line 31, in 
    from googlecloudsdk.core.resource import session_capturer
  File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/resource/session_capturer.py", line 32, in 
    from googlecloudsdk.core.resource import yaml_printer
  File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/resource/yaml_printer.py", line 17, in 
    from googlecloudsdk.core.resource import resource_printer_base
  File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/resource/resource_printer_base.py", line 38, in 
    from googlecloudsdk.core.resource import resource_projector
  File "/Users/julian/google-cloud-sdk/lib/googlecloudsdk/core/resource/resource_projector.py", line 34, in 
    from google.protobuf import json_format as protobuf_encoding
ImportError: cannot import name json_format

I tried gcloud update and gcloud reinstall but still get same problem. Is there a conflict with the python installation? Any other ideas?

like image 278
julian Avatar asked Nov 09 '17 11:11

julian


3 Answers

You can also fix this error by updating to the latest version of protobuf. Then you don't have to downgrade gcloud.

pip install protobuf --upgrade
like image 89
Stephen H Avatar answered Sep 19 '22 00:09

Stephen H


The issue occurs when you have google protobuf package installed.

You can work around the problem either by using older version by running

gcloud components update --version 175.0.0

or by removing google protobuf package the python installation.

pip remove protobuf

If you do not want to do either of these, they can install a separate version of 2.7 python (without protobuf) and set CLOUDSDK_PYTHON=/path/to/python environment variable.

Also next release of cloud sdk should have this fix.

like image 42
cherba Avatar answered Sep 17 '22 00:09

cherba


I had the same issue. I am using a mac. Looking into /usr/local/lib/python2.7/site-packages i found a homebrew protobuf link. I removed it with "rm homebrew-protobuf.pth" Then gsutil started working.

like image 43
alunarbeach Avatar answered Sep 18 '22 00:09

alunarbeach