Google-cloud-python: BigQuery: Client initiation fails in Google Cloud Functions

Created on 9 Jun 2019  路  4Comments  路  Source: googleapis/google-cloud-python

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  1. Specify the API at the beginning of the title (for example, "BigQuery: ...")
    General, Core, and Other are also allowed as types
  2. OS type and version
  3. Python version and virtual environment information: python --version
  4. google-cloud- version: pip show google-<service> or pip freeze

Steps to reproduce

  1. Use google-cloud-bigquery in any cloud functions
  2. following code is going to fail

Code example

from google.cloud import bigquery
def test_function(data, context):
  client = bigquery.Client()

Stack trace

File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 383, in run_background_function _function_handler.invoke_user_function(event_object) File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 217, in invoke_user_function return call_user_function(request_or_event) File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 214, in call_user_function event_context.Context(**request_or_event.context)) File "/user_code/main.py", line 11, in upload_bq bq = bigquery.Client() File "/user_code/google/cloud/bigquery/client.py", line 167, in __init__ self._connection = Connection(self, client_info=client_info) File "/user_code/google/cloud/bigquery/_http.py", line 33, in __init__ super(Connection, self).__init__(client, client_info) TypeError: __init__() takes 2 positional arguments but 3 were given

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

question bigquery

Most helpful comment

I'm getting this error as well, and I have updated all google cloud python libraries. I have google-cloud-core v 1.11.1.

All 4 comments

@ashuvashu You have an out-of-date version of google-cloud-core installed in your environment. google-cloud-bigquery 1.12.0 and later require google-cloud-core >= 1.0.0.

I'm getting this error as well, and I have updated all google cloud python libraries. I have google-cloud-core v 1.11.1.

@ctivanovich Can you please show the requirements.txt for your Cloud Functions environment?

I have found that this requirements.txt works on a fresh Ubuntu 18.04 install:

google-cloud-bigquery==1.19.0
google-cloud-core==1.0.3

By "works" I mean you can create a BigQuery Client object and obtain a Table object from it.

Was this page helpful?
0 / 5 - 0 ratings