Reputation: 2876
I'm running the python script below on Google Cloud Functions and I have the following error:
Error: function terminated. Recommended action: inspect logs for termination reason. Details:
name 'six' is not defined
Here is my script:
from google.cloud import bigquery
client = bigquery.Client()
def run(request):
csv_file = six.BytesIO(b"""full_name,age
Phred Phlyntstone,32
Wylma Phlyntstone,29
""")
table_ref = dataset.table('ga-online-audit:test_python.test')
job_config = bigquery.LoadJobConfig()
job_config.source_format = 'CSV'
job_config.skip_leading_rows = 1
job = client.load_table_from_file(
csv_file, table_ref, job_config=job_config) # API request
job.result() # Waits for table load to complete.
Here is my requirements txt file:
# Function dependencies, for example:
# package>=version
google-cloud-logging
google-cloud-error-reporting
google-cloud-bigquery
six==1.13.0
Upvotes: 0
Views: 388
Reputation: 8204
You've declared a dependency on six but you still need to import it in the script.
import six
six.BytesIO(...)
Upvotes: 3