【问题标题】:'six' is not defined. requirements library issue“六”没有定义。需求库问题
【发布时间】:2019-12-13 00:30:20
【问题描述】:

我在 Google Cloud Functions 上运行下面的 python 脚本,但出现以下错误:

Error: function terminated. Recommended action: inspect logs for termination reason. Details: name 'six' is not defined

这是我的脚本:

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.

这是我的需求 txt 文件:

# Function dependencies, for example:
# package>=version
google-cloud-logging
google-cloud-error-reporting
google-cloud-bigquery
six==1.13.0

【问题讨论】:

    标签: python python-3.x google-cloud-functions


    【解决方案1】:

    你已经声明了对六个的依赖,但你仍然需要在脚本中导入它。

    import six
    six.BytesIO(...)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-13
      • 2018-08-29
      • 1970-01-01
      相关资源
      最近更新 更多