discovery.build调用导致python停止工作

时间:2016-04-01 00:54:35

标签: python google-drive-api

我一直在制作一个脚本,将.csv文件上传到谷歌硬盘。该剧本全天都在工作,但最近它已经崩溃/导致python停止工作。我打电话时似乎崩溃了:

service = discovery.build('drive', 'v3', http=http)

以下是脚本的主要功能:

def main():
    credentials = get_credentials()
    http = credentials.authorize(httplib2.Http())
    service = discovery.build('drive', 'v3', http=http)
    #upload to Reload Folder
    folder_id = 'RealIdExcluded'
    file_metadata = {
        'name': 'allStats.csv',
        'mimeType' : 'application/vnd.google-apps.spreadsheet' 
    }

    media = MediaFileUpload('statOutput.csv',
                            mimetype = 'text/csv',
                            resumable = True)
    file = service.files().update(body= file_metadata,
                                    media_body=media,
                                    fields = 'id',
                                    fileId = 'RealIdExcluded').execute()
    print('File ID: %s' % file.get('id'))

任何帮助都很棒。感谢

1 个答案:

答案 0 :(得分:0)

I never figured out what the problem was, but I uninstalled python and reinstalled which seemed to fix the issue.