skip to Main Content

I’m running a VM instance (google compute engine) with CENTOS 7, everytime i run the bq command, i keep getting error. I supposed bq is by default in compute engine.


[username@instance-1 ~]$ bq
Error initializing bq client: service_account
Traceback (most recent call last):
  File "/usr/lib64/google-cloud-sdk/platform/bq/third_party/pyglib/appcommands.py", line 805, in _CommandsStart
    sys.modules['__main__'].main(GetCommandArgv())
  File "/usr/lib64/google-cloud-sdk/platform/bq/bq.py", line 6078, in main
    if FLAGS.debug_mode or FLAGS.headless:
  File "/usr/lib64/google-cloud-sdk/platform/bq/third_party/absl/flags/_flagvalues.py", line 468, in __getattr__
    raise AttributeError(name)
AttributeError: debug_mode
FATAL error in main: debug_mode
Run 'bq.py help' to get help
[username@instance-1 ~]$ bq --format=prettyjson dataset.tableid
FATAL Flags parsing error: Unknown command line flag 'use_gce_service_account'
Run 'bq.py help' to get help
[username@instance-1 ~]$ 

my compute engine account has full full access to all Cloud APIs, in addition just to be sure, i also add bigquery admin in the IAM part.

I’m not really sure what is wrong.

2

Answers


  1. You might have a bash alias acting wrong or a ~/.bigqueryrc

    Check the syntax and the correct service account files inside ~/.bigqueryrc

    Login or Signup to reply.
  2. Have a look at the documentation:

    The bq authorization flags are deprecated. To configure authorization
    for the bq command-line tool, see Authorizing Cloud SDK tools.

    and also in this section you can find flag that cause an error:

    –use_gce_service_account

    I’ve tried to run at my linux machine with Google Cloud SDK command bq and it works perfectly:

    $ bq        
    Python script for interacting with BigQuery.
    
    
    USAGE: bq.py [--global_flags] <command> [--command_flags] [args]
    
    
    Any of the following commands:
      cancel, cp, extract, get-iam-policy, head, help, init, insert, load, ls, mk, mkdef, partition, query, rm, set-iam-policy, shell,
      show, update, version, wait
    

    At first, you should update your Cloud SDK to the latest version (or reinstall it) and check again. Also, please update your post with version of your Cloud SDK:

    $ gcloud info       
    Google Cloud SDK [277.0.0]
    
    Python Version: [3.7.5rc1 (default, Dec 20 2019, 17:52:56)  [GCC 8.3.0]]
    Python Location: [/usr/bin/python3]
    

    If you have en error with the latest Cloud SDK, try set up default values for bq in $HOME/.bigqueryrc as it described in the documentation.

    In addition, I’d recommend you to check/update Python if nothing helps.

    EDIT You can set up defaults in your ~/.bigqueryrc file like this:

    project_id = --my-project-id--
    

    in your favorite text editor like nano or vim. Keep in mind that file paths in .bigqueryrc had to be the full path.

    EDIT2 Have a look at the Cloud SDK system requirements:

    It requires Python 2.7.9 or higher.

    and you have 2.7.5.

    UPDATE Deleting and reinstalling the Cloud SDK solved the problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search